<filename>examples/04_light_change.py
# import the GPIO module
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

def red_light_on():
    # turn the light on
    GPIO.output(light_red, True)

def red_light_off():
    # turn the light off
    GPIO.output(light_red, False)

def yellow_light_on():
    # turn the light on
    GPIO.output(light_yellow, True)

def yellow_light_off():
    # turn the light off
    GPIO.output(light_yellow, False)

def green_light_on():
    # turn the light on
    GPIO.output(light_green, True)

def green_light_off():
    # turn the light off
    GPIO.output(light_green, False)

# set which pin number we used for the lights
light_red = 26
light_yellow = 19
light_green = 13

# setup the pins as an output
GPIO.setup(light_red, GPIO.OUT)
GPIO.setup(light_yellow, GPIO.OUT)
GPIO.setup(light_green, GPIO.OUT)

# turn on the green light for go
red_light_off()
yellow_light_off()
green_light_on()

# wait for 3 seconds
time.sleep(3)

# switch to amber light
red_light_off()
yellow_light_on()
green_light_off()

# wait for 3 seconds
time.sleep(3)

# switch to red light for stop
red_light_on()
yellow_light_off()
green_light_off()

# wait for 5 seconds
time.sleep(5)

<filename>examples/04_light_change.py
# import the GPIO module
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

def red_light_on():
    # turn the light on
    GPIO.output(light_red, True)

def red_light_off():
    # turn the light off
    GPIO.output(light_red, False)

def yellow_light_on():
    # turn the light on
    GPIO.output(light_yellow, True)

def yellow_light_off():
    # turn the light off
    GPIO.output(light_yellow, False)

def green_light_on():
    # turn the light on
    GPIO.output(light_green, True)

def green_light_off():
    # turn the light off
    GPIO.output(light_green, False)

# set which pin number we used for the lights
light_red = 26
light_yellow = 19
light_green = 13

# setup the pins as an output
GPIO.setup(light_red, GPIO.OUT)
GPIO.setup(light_yellow, GPIO.OUT)
GPIO.setup(light_green, GPIO.OUT)

# turn on the green light for go
red_light_off()
yellow_light_off()
green_light_on()

# wait for 3 seconds
time.sleep(3)

# switch to amber light
red_light_off()
yellow_light_on()
green_light_off()

# wait for 3 seconds
time.sleep(3)

# switch to red light for stop
red_light_on()
yellow_light_off()
green_light_off()

# wait for 5 seconds
time.sleep(5)

# import the GPIO module # turn the light on # turn the light off # turn the light on # turn the light off # turn the light on # turn the light off # set which pin number we used for the lights # setup the pins as an output # turn on the green light for go # wait for 3 seconds # switch to amber light # wait for 3 seconds # switch to red light for stop # wait for 5 seconds