"""
filename:gpio_RPi_pedestrianCrossing.py
Further Project - Pedestrian Crossing
written by Trevor Olsson
© GPIO Support Services LTD MMXVII
More info here: http://www.gpio.co.uk/pedestrian-crossing
"""
from gpiozero import Button, LED
import time
btn=Button(4,pull_up=False)
r_lamp=LED(17)
y_lamp=LED(18)
g_lamp=LED(27)
r_man=LED(22)
g_man=LED(23)
wait_lamp=LED(24)
r_lamp.off()
y_lamp.off()
g_lamp.on()
r_man.on()
g_man.off()
wait_lamp.off()
while True:
if btn.is_pressed:
wait_lamp.on()
time.sleep(2)
g_lamp.off()
y_lamp.on()
time.sleep(2)
y_lamp.off()
r_lamp.on()
time.sleep(2)
wait_lamp.off()
r_man.off()
g_man.on()
time.sleep(5)
r_man.on()
g_man.off()
time.sleep(2)
y_lamp.on()
time.sleep(2)
r_lamp.off()
y_lamp.off()
g_lamp.on()
Comments