Report Bugs Here

Moderator: Mmiscool

User avatar
By JMS
#40190 This is a section of code that has worked well for me utilizing the interrupt to detect a button press. The time that it takes between the interrupt being triggered and the time that "switchPin" is reread seems to be enough that no debounce is needed.

Code: Select all 
[buttonPress]<----------------------------------------- Interrupt Triggered 
interrupt switchPin  <---------------------------------Disable the interrupt for now
pi switchPin pinState<-------------------------------Reread switchPin 
interrupt switchPin [buttonPress]<---------------Reset interupt
if pinState = 1 then goto [flipFlop] <---------------If button was pressed Goto section that turns on or off the relay pin.
goto [webState] <--------------------------------------Goes to section that draws a webpage.  It's the steady state section where the program sits when nothing else is going on.
wait
User avatar
By Mmiscool
#40210 Just uploaded a new build that makes it possible to check the last polled value of a pin or the last status you set it to.

print io(laststat,pin)

This will return the last polled status of a pin such as an interrupt and retain the value until it has changed again in another polling event. Also it will allow you to see the last value sent to a pin for servo, pwm or po.