mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Convert recipe examples to includes
Makes it much easier to test things - no copying'n'pasting just run the examples straight from the dir (after wiring stuff up)
This commit is contained in:
20
docs/examples/traffic_lights_2.py
Normal file
20
docs/examples/traffic_lights_2.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from gpiozero import TrafficLights
|
||||
from time import sleep
|
||||
from signal import pause
|
||||
|
||||
lights = TrafficLights(2, 3, 4)
|
||||
|
||||
def traffic_light_sequence():
|
||||
while True:
|
||||
yield (0, 0, 1) # green
|
||||
sleep(10)
|
||||
yield (0, 1, 0) # amber
|
||||
sleep(1)
|
||||
yield (1, 0, 0) # red
|
||||
sleep(10)
|
||||
yield (1, 1, 0) # red+amber
|
||||
sleep(1)
|
||||
|
||||
lights.source = traffic_light_sequence()
|
||||
|
||||
pause()
|
||||
Reference in New Issue
Block a user