i am trying to learn rpi interrupt programming using two buttons but its showing error during execution.
can anyone please help me.
Here is my code:
import RPi.GPIO as GPIO
import os
GPIO.setmode(GPIO.BOARD)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def my_callback(channel):
print "falling edge detected on 23"
os.system("date")
GPIO.add_event_detect(23, GPIO.FALLING, callback=my_callback, bouncetime=300)
try:
print "Waiting for falling edge on port 24"
GPIO.wait_for_edge(24, GPIO.FALLING)
print "falling edge detected on port 24, end of program"
except KeyboardInterrupt:
GPIO.cleanup()
GPIO.cleanup()
if i remove the statement os.system("date") from the scipt everything works fine. but when insert the above code into the script it gives "RuntimeError: Error #5 waiting for edge"
anyone be able tp modify the code to working condition
thanks in advance