-
Notifications
You must be signed in to change notification settings - Fork 0
/
RPi-traficlights-python.py
94 lines (75 loc) · 1.85 KB
/
RPi-traficlights-python.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18,GPIO.OUT) # Pin usage GPIO Pin 18
GPIO.setup(17,GPIO.OUT) # Pin usage GPIO Pin 17
GPIO.setup(27,GPIO.OUT) # Pin usage GPIO Pin 27
while True: # Loop for ever
print('START') # Say in Terminal
GPIO.output(18,GPIO.HIGH) # Set GPIO Pin "High"
print('LED RED ON') # Say in Terminal
print('WAIT 5s') # Say in Terminal
time.sleep(5) # Waiting
print('DONE WAITING') # Say in Terminal
GPIO.output(17,GPIO.HIGH)
print('LED YELLOW ON')
print('WAIT 1s')
time.sleep(1)
print('DONE WAITING')
GPIO.output(17,GPIO.LOW)
print('LED YELLOW OFF')
GPIO.output(18,GPIO.LOW)
print('LED RED OFF')
GPIO.output(27,GPIO.HIGH)
print('LED GREEN ON')
print('WAIT 5s')
time.sleep(5)
print('DONE WAITING')
GPIO.output(27,GPIO.LOW)
print('LED GREEN OFF')
print('WAIT 1s')
time.sleep(1)
GPIO.output(27,GPIO.HIGH)
print('LED GREEN ON')
print('WAIT 1s')
time.sleep(1)
GPIO.output(27,GPIO.LOW)
print('LED GREEN OFF')
print('WAIT 1s')
time.sleep(1)
GPIO.output(27,GPIO.HIGH)
print('LED GREEN ON')
print('WAIT 1s')
time.sleep(1)
GPIO.output(27,GPIO.LOW)
print('LED GREEN OFF')
print('WAIT 1s')
time.sleep(1)
GPIO.output(27,GPIO.HIGH)
print('LED GREEN ON')
print('WAIT 1s')
time.sleep(1)
GPIO.output(27,GPIO.LOW)
print('LED GREEN OFF')
print('WAIT 1s')
time.sleep(1)
GPIO.output(27,GPIO.HIGH)
print('LED GREEN ON')
print('WAIT 1s')
time.sleep(1)
GPIO.output(27,GPIO.LOW)
print('LED GREEN OFF')
print('WAIT 1s')
time.sleep(1)
GPIO.output(17,GPIO.HIGH)
print('LED YELLOW ON')
print('WAIT 1s')
time.sleep(1)
GPIO.output(17,GPIO.LOW)
print('LED YELLOW OFF')
print('WAIT 1s')
print('END')
GPIO.output(17,GPIO.LOW)
GPIO.output(18,GPIO.LOW)
GPIO.output(27,GPIO.LOW)