import time import Adafruit_BBIO.GPIO as GPIO GPIO.setup("P9_15",GPIO.OUT) inPin = "P9_12" GPIO.setup(inPin, GPIO.IN) GPIO.add_event_detect(inPin,GPIO.RISING) try: time.sleep(2) while True: if GPIO.event_detected("P9_12"): GPIO.output("P9_15",GPIO.HIGH) time.sleep(0.5) GPIO.output("P9_15",GPIO.LOW) print("Motion detected...") time.sleep(3) else: print("---") GPIO.output("P9_15",GPIO.LOW) #sleep(0.5) #GPIO.output("P9_15",GPIO.LOW) #sleep(0.5) #GPIO.output("P9_15",GPIO.HIGH) #sleep(0.5) #GPIO.output("P9_15",GPIO.LOW) time.sleep(2) except: GPIO.cleanup()