SHARE
TWEET

Toddler Toilet Timer

sweenig Sep 7th, 2017 18 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print("Initializing...")
  2. from gpiozero import TrafficHat
  3. from time import sleep
  4. redtime=10
  5. ambertime=3
  6. greentime=30
  7. buzzertime=3
  8. a = TrafficHat()
  9. a.lights.red.blink(0.1,0.2,10)
  10. sleep(0.1)
  11. a.lights.amber.blink(0.1,0.2,10)
  12. sleep(0.1)
  13. a.lights.green.blink(0.1,0.2,10,False)
  14. while True:
  15.   print("Waiting for button press...")
  16.   a.button.wait_for_press()
  17.   #turn on red light and periodic beep
  18.   a.lights.red.on()
  19.   a.buzzer.beep(0.1,1.9,int(redtime/2),False)
  20.   a.lights.red.off()
  21.   #switch to amber light and faster beep
  22.   a.lights.amber.on()
  23.   a.buzzer.beep(0.1,0.9,ambertime,False)
  24.   a.lights.amber.off()
  25.   #switch to green light and fast beep
  26.   a.lights.green.on()
  27.   a.buzzer.beep(0.1,0.1,int(buzzertime/0.2),False)
  28.   sleep(greentime-buzzertime)
  29.   a.off()
RAW Paste Data
Top