Author Topic: [ISSUE] RisingEdge + FallingEdge events in the same script  (Read 43 times)

macman31

  • Newbie
  • *
  • Posts: 2
    • View Profile
[ISSUE] RisingEdge + FallingEdge events in the same script
« on: August 06, 2016, 03:27:44 pm »
Hello,

I'm trying to make the following script work:

Code: [Select]
Define PinMode Pin0 As DigitalInputPullDown
Class PIR
    Shared Event Boot()
        LedGreen = False
        LedRed = False
    End Event
    Shared Event Pin0RisingEdge()
        LedRed = True
        Thread.Sleep(100000)
        LedRed = False
    End Event
    Shared Event Pin0FallingEdge()
        LedGreen = True
        Thread.Sleep(100000)
        LedGreen = False
    End Event
End Class

The issue is that with the latest availble versions of the different softwares, only the FallingEdge event is executed.
The green LED lights as expected on FallingEdge events, but nothing happens on RisingEdge events.

If I comment the falling edge event, then the rising edge event is executed on rising edges: the red LED lights!

My question is: why this behavior? What am I missing? How can I script the behavior "red LED on rising edge on pin 0, green LED on falling edge on pin 0"?

Thanks!

Share on Facebook Share on Twitter


mc-Abe

  • Full Member
  • ***
  • Posts: 167
    • View Profile
    • mc-Things
At the moment, you can only set one event type per pin. Please use P0Changed() event and check the value of the Pin to see if it was a falling or rising edge event.

macman31

  • Newbie
  • *
  • Posts: 2
    • View Profile
Ok, thank you for your answer!