User manual

43
GPIO.setup(light[blue], GPIO.OUT, initial=False)
GPIO.setup(light[button], GPIO.IN)
print (“Press button to turn on pedestrian light,
“Ctrl+C exits the program")
try:
while True:
if GPIO.input(light[button])==True:
GPIO.output(light[green],False)
GPIO.output(lightl[yellow],True)
time.sleep(0.6)
GPIO.output(light[yellow],False)
GPIO.output(light[red],True)
time.sleep(0.6)
for i in range(10):
GPIO.output(light[blue],True); time.sleep(0.05)
GPIO.output(light[blue],False); time.sleep(0.05)
time.sleep(0.6)
GPIO.output(lightl[yellow],True)
time.sleep(0.6)
GPIO.output(light[red],False); GPIO.output(light[yellow],False)
GPIO.output(lightl[green],True); time.sleep(2)
except KeyboardInterrupt:
GPIO.cleanup()
4.2.1 How does it work?
Some features have been added to the program with respect to the previous version.
# -*- coding: utf-8 -*- To display for instance the German umlauts of Fußgängerblinklicht that is
pedestrian flashing light -correctly in the program output - regardless of how the user’s IDLE surface is set up
- we start with defining an encoding for the representation of special characters. This line should be included
in all programs that will display texts which contain umlauts or other country-specific special characters.
ASCII, ANSI and Unicode
The alphabet consists of 26 letters plus a few special characters, all in uppercase and lowercase, plus ten
digits, and some punctuation; that adds up to about 100 different characters. 256 different characters can
be represented by one byte. That should be sufficient - so they thought at the beginning of computer
history when the basics of today's technology were defined.
Very soon it turned out that the inventor of the ASCII character set (American Standard Code for
Information Interchange), which is based on 256 characters, was wrong. They were Americans who had
not looked beyond the English-speaking world. In all major languages of the world, that goes without
even mentioning the Asian and Semitic languages with their own writing systems, feature hundreds of
letters that need to be represented. Few of those found a free space in the list consisting of 256
characters.