Author Topic: mc-Dev Board is now available for purchase!  (Read 146 times)

mc-T2

  • Administrator
  • Sr. Member
  • *****
  • Posts: 252
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Re: mc-Dev Board is now available for purchase!
« on: June 30, 2016, 03:16:02 pm »
Here is the code for the example project from the Video.
We attached a light sensor alongside a 2.2K resistor and then measured the light intensity. The code allows the LED lights on the mc-Dev board to visualize the light levels within the room by lighting up when high intensity light is present and to decrease when the light level drops. Very neat and simple to do!
Code: [Select]
Define PinMode Pin2 As AnalogInput Alias lightVoltage
Define PinMode Pin3 As DigitalOutput
Define PinMode Pin4 As DigitalOutput
Define PinMode Pin5 As DigitalOutput
Define PinMode Pin6 As DigitalOutput
Define PinMode Pin7 As DigitalOutput
Define PinMode Pin8 As DigitalOutput
Class ldrTest
    Shared Event Boot()
        Pin3 = False
        Pin4 = False
        Pin5 = False
        Pin6 = False
        Pin7 = False
        Pin8 = False
        LedRed = False
        LedGreen = False
    End Event
    Shared Event measureLight() RaiseEvent Every 50 milliSeconds
        Thread.Sleep(20000) 'sleep 20ms for voltage to stabilize
        Dim voltage As Short = lightVoltage
        If voltage > 3000 Then
            Pin3 = True
            Pin4 = True
            Pin5 = True
            Pin6 = True
            Pin7 = True
            Pin8 = True
        ElseIf voltage <= 3000 And voltage >= 2500 Then
            Pin3 = False
            Pin4 = True
            Pin5 = True
            Pin6 = True
            Pin7 = True
            Pin8 = True
        ElseIf voltage <= 2499 And voltage >= 2000 Then
            Pin3 = False
            Pin4 = False
            Pin5 = True
            Pin6 = True
            Pin7 = True
            Pin8 = True
        ElseIf voltage <= 1999 And voltage >= 1500 Then
            Pin3 = False
            Pin4 = False
            Pin5 = False
            Pin6 = True
            Pin7 = True
            Pin8 = True
        ElseIf voltage <= 1499 And voltage >= 1000 Then
            Pin3 = False
            Pin4 = False
            Pin5 = False
            Pin6 = False
            Pin7 = True
            Pin8 = True
        ElseIf voltage < 999 And voltage >= 500 Then
            Pin3 = False
            Pin4 = False
            Pin5 = False
            Pin6 = False
            Pin7 = False
            Pin8 = True
        ElseIf voltage < 500 Then
            Pin3 = False
            Pin4 = False
            Pin5 = False
            Pin6 = False
            Pin7 = False
            Pin8 = False
        Else   
        End If
    End Event
    'Battery check
    Shared Event measureVoltage() RaiseEvent Every 2 Hours
        Dim BattVolt As Short = Device.BatteryVoltage
        If BattVolt < 2200 Then
            Lplan.IFTTT("mjgu7QocyzTNDUbzgitzHxBYPFaXckJrJ2LbLq8XMMg", "GarageBatt")
        Else
        End If
    End Event
End Class
Need more mc-Modules, mc-Gateways or other mc-Things? Check out our product page: www.mcthings.com/products. mc-Development kits are available too!
Check out a live Dashboard using mcThings and Losant! Click here: https://goo.gl/ST43hB