Created
April 2, 2020 12:24
-
-
Save oschettler/fe1173304da8ceb750eea7e7e104d20e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Traffic lights | |
from gpiozero import LED | |
from time import sleep | |
from gpiozero.pins.pigpio import PiGPIOFactory | |
factory = PiGPIOFactory(host='raspberrypi') | |
red_led = LED(17, pin_factory=factory) | |
yellow_led = LED(27, pin_factory=factory) | |
green_led = LED(22, pin_factory=factory) | |
def cycle(): | |
red_led.on() | |
yellow_led.off() | |
green_led.off() | |
sleep(2) | |
yellow_led.on() | |
sleep(1) | |
red_led.off() | |
yellow_led.off() | |
green_led.on() | |
sleep(2) | |
yellow_led.on() | |
green_led.off() | |
sleep(1) | |
while True: | |
cycle() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment