Author Topic: mcModule as doorbell  (Read 22 times)

mc-T2

  • Administrator
  • Sr. Member
  • *****
  • Posts: 252
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Re: mcModule as doorbell
« on: August 27, 2018, 09:51:05 am »
@michaelblight - you are correct, i think i put in the wrong code for you. There is a button on the mcMod's that you can use - it is predefined within the langage script (as button) and can be used. However, this button will be quite touch for someone to press as a doorbell. Here is code that is better suited to what you want to do (With a button soldered to pin0 and GND):

Code: [Select]
Define PinMode Pin0 As DigitalInputPullupWeak
Class mcSwitch
   
   
   
    //The following will send an IFTTT message when the button is pressed & will light the LED when pressed
    Shared Event Pin0FallingEdge()     
        Thread.Sleep(50000)
        'This timing may need To be modified but essentially this Is a debounce.After the device detects a change it waits 50 ms To check again To confirm that the button was actually pushed * *
        Thread.ClearHardwareEvent()
        If Pin0 = False Then
            Lplan.IFTTT("YOURIFTTTKEYHERE", "BUTTON")
            LedGreen = True // turn off LED
            Thread.Sleep(100000)
            LedGreen = False
            Thread.Sleep(30000000)
            'This can also be modified.After the above program runs, the module will Not be able To run it again For 120 Seconds / 2 Minutes (the timing Is In microSeconds).If you want, you can change this To 6000000 which will give you 60 Seconds before the button can be pressed again.
        End If
    End Event
End Class
   
End Class

Hope that helps
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