Week6-8_Interrupt_Test2
import RPi.GPIO as GPIO
import time
def fall(channel):
print('detected!')
GPIO.output(5, True)
time.sleep(0.1)
GPIO.output(5, False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(5, GPIO.OUT)
GPIO.setup(6, GPIO.IN)
GPIO.add_event_detect(6, GPIO.FALLING,
callback=lambda x:fall(6), bouncetime=300)
try:
while True:
pass
finally:
print('cleaning up')
GPIO.cleanup() detected! detected! detected! detected! detected! detected!