Interactive traffic lights with pygame-zero and gpiozero
- Clone this repo:
git clone https://github.com/bennuttall/pgz-traffic-lights
- Enter the directory:
cd pgz-traffic-lights
- Change the line
lights = TrafficLights(2, 3, 4)
to match your traffic light pin numbers (red, amber green) - Run with
pgzrun trafficlights.py
- Click a colour to light an LED
Also see trafficlights2.py
which is a variation in code achieving the same result.