Software Setup

LED control

The three LEDs are setup in such a way that a high voltage turns the LEDs ON. In terms that the Python module understands that means to turn on an LED you set the output pin to True.

The LEDs are connected to the following pins:

pin 9 = Red LED

pin 10 = Yellow LED

pin 11 = Green LED

In Python the pins first need to be setup as outputs then set to True to turn the LED on or False to turn the LED off.

# Pin Setup:
GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme. This uses the pin numbers that match the pin numbers on the Pi Traffic light.
GPIO.setup(9, GPIO.OUT) # Red LED pin set as output
# Set the pin HIGH
GPIO.output(9, True) # Turns on the Red LED
# Set the pin LOW
GPIO.output(9, False) # Turns off the Red LED

To use the Yellow and Green LEDs first set those pins to output:

GPIO.setup(10, GPIO.OUT) # Yellow LED pin set as output
GPIO.setup(11, GPIO.OUT) # Green LED pin set as output