Python IF statement to see how long an input has been active
I am using a raspberry pi, a pi face and a python script to monitor
several home sensors. I want to add the sensing wire from the smoke
detectors to that list but I need a bit of help with the if statement.
I'm unsure how to tell the if statement to check how long the input has
detected the signal. Under 4 seconds disregard (low battery chirp), over 4
seconds (smoke detected) alert me..
Basically I need help writing the if statement below.
if piface.digital_read(0)==0 >= 4 seconds:
# do x
else:
# do y
Do I need a loop and can it be as easy as what I have above? (Coded
correctly of course!)
No comments:
Post a Comment