User manual

33
Fig. 3.2: A simple traffic light.
The program ampel01.py controls the light:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
red = 0; yellow = 1; green = 2
Light=[4,18,23]
GPIO.setup(light[red], GPIO.OUT, initial=False)
GPIO.setup(light[yellow], GPIO.OUT, initial=False)
GPIO.setup(light[green], GPIO.OUT, initial=True)
print ("Strg+C exits the program")
try:
while True:
time.sleep(2)
GPIO.output(light[green],False); GPIO.output(light[yelllow],True)
time.sleep(0.6)