User manual

45
When starting the programme, a message is displayed that notifies the user to press the button
while True:
if GPIO.input(light[button])==True:
Within the loop, a query is now set up. The following statements are only executed when the GPIO port 25
has the value
True, that is, the user presses the button. Until then, the traffic light will be in the green state.
The rest of the loop’s process basically corresponds to the previous programme. The traffic light turns to
yellow and then to red, the flashing light flashes ten times. Then the lights returns from red to yellow and to
green.
time.sleep(2) However there is a tiny deviation in this program. The green phase of 2 seconds is now built
in at the end of the loop and no longer at the beginning. Nevertheless it is applied once for each loop run,
with the difference that the traffic light cycle starts immediately and without delay as soon as the button is
pressed. This delay is now included at the end of the loop to prevent the green phase from failing when the
button is immediately pressed again after the yellow phase.
5 Colorful LED patterns and chaser lights
Chaser lights are popular effects in order to arouse attention, whether it is used in a party room in the
basement or in professional illuminated signage. This can be easily realized using the Raspberry Pi and a few
LEDs.
Set up four LEDs with series resistors for the following experiment as illustrated. This circuit corresponds to
the pedestrian lights without button used in the previous experiment.
Fig. 5.1: Breadboard assembly for the samples and the chaser lights.