Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def PlaySequence():
- GPIO.output(LED1, True)
- time.sleep(5)
- GPIO.output(LED2, True)
- time.sleep(1)
- GPIO.output(LED1, False)
- time.sleep(3)
- GPIO.output(LED1, True)
- GPIO.output(LED2, True)
- time.sleep(7)
- GPIO.output(LED2, False)
- time.sleep(12)
- GPIO.output(LED1, True)
- time.sleep(2)
- ...
- GPIO.add_event_detect(button, GPIO.RISING, callback=PlaySequence)
- event press detected
- loop
- if gpio pin is low
- turn off all leds
- break loop
- def PlaySequence(button):
- GPIO.output(LED1, True)
- if not GPIO.input(button):
- return
- time.sleep(5)
- GPIO.output(LED2, True)
- if not GPIO.input(button):
- return
- time.sleep(1)
- GPIO.output(LED1, False)
- if not GPIO.input(button):
- return
- time.sleep(3)
- GPIO.output(LED1, True)
- GPIO.output(LED2, True)
- if not GPIO.input(button):
- return
- time.sleep(7)
- GPIO.output(LED2, False)
- if not GPIO.input(button):
- return
- time.sleep(12)
- GPIO.output(LED1, True)
- if not GPIO.input(button):
- return
- time.sleep(2)
Add Comment
Please, Sign In to add comment