Advertisement
gPiOBox

Further - Pedestrian Crossing

Oct 23rd, 2017
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. """
  2. filename:gpio_RPi_pedestrianCrossing.py
  3. Further Project - Pedestrian Crossing
  4. written by Trevor Olsson
  5. © GPIO Support Services LTD MMXVII
  6. More info here: http://www.gpio.co.uk/pedestrian-crossing
  7. """
  8. from gpiozero import Button, LED
  9. import time
  10.  
  11. btn=Button(4,pull_up=False)
  12. r_lamp=LED(17)
  13. y_lamp=LED(18)
  14. g_lamp=LED(27)
  15. r_man=LED(22)
  16. g_man=LED(23)
  17. wait_lamp=LED(24)
  18.  
  19. r_lamp.off()
  20. y_lamp.off()
  21. g_lamp.on()
  22. r_man.on()
  23. g_man.off()
  24. wait_lamp.off()
  25.  
  26. while True:
  27.  
  28.     if btn.is_pressed:
  29.         wait_lamp.on()
  30.         time.sleep(2)
  31.         g_lamp.off()
  32.         y_lamp.on()
  33.         time.sleep(2)
  34.         y_lamp.off()
  35.         r_lamp.on()
  36.         time.sleep(2)
  37.         wait_lamp.off()
  38.         r_man.off()
  39.         g_man.on()
  40.         time.sleep(5)
  41.         r_man.on()
  42.         g_man.off()
  43.         time.sleep(2)
  44.         y_lamp.on()
  45.         time.sleep(2)
  46.         r_lamp.off()
  47.         y_lamp.off()
  48.         g_lamp.on()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement