Raspberry Pi Pinout

Traffic HAT

A quick and easy way to learn the basics of GPIO on a budget. All in a nice HAT.

from gpiozero import TrafficHat
from time import sleep
from signal import pause

hat = TrafficHat()

# control components individually
hat.lights.green.on()
sleep(1)
hat.lights.amber.on()
sleep(1)
hat.lights.red.on()
sleep(1)
hat.buzzer.on()
sleep(1)
hat.off()  # turn everything off

# set up events on button press/release
hat.button.when_pressed = hat.lights.blink
hat.button.when_released = hat.lights.off

pause()

Details

Traffic HAT