forked from sbcshop/PiTraffic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrafficTest.py
More file actions
84 lines (65 loc) · 1.7 KB
/
TrafficTest.py
File metadata and controls
84 lines (65 loc) · 1.7 KB
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
import PiTraffic
import time
SouthRed = PiTraffic.Traffic("SOUTH", "RED")
SouthYellow = PiTraffic.Traffic("SOUTH", "YELLOW")
SouthGreen = PiTraffic.Traffic("SOUTH", "GREEN")
EastRed = PiTraffic.Traffic("EAST", "RED")
EastYellow = PiTraffic.Traffic("EAST", "YELLOW")
EastGreen = PiTraffic.Traffic("EAST", "GREEN")
NorthRed = PiTraffic.Traffic("NORTH", "RED")
NorthYellow = PiTraffic.Traffic("NORTH", "YELLOW")
NorthGreen = PiTraffic.Traffic("NORTH", "GREEN")
WestRed = PiTraffic.Traffic("WEST", "RED")
WestYellow = PiTraffic.Traffic("WEST", "YELLOW")
WestGreen = PiTraffic.Traffic("WEST", "GREEN")
Buzz = PiTraffic.Buzzer()
# All direction RED LED ON
def AllRed():
SouthRed.on()
EastRed.on()
NorthRed.on()
WestRed.on()
AllRed()
try:
while True:
Buzz.on()
time.sleep(0.2)
Buzz.off()
EastRed.off()
EastYellow.on()
time.sleep(1)
EastYellow.off()
EastGreen.on()
time.sleep(2)
EastGreen.off()
EastRed.on()
time.sleep(1)
WestRed.off()
WestYellow.on()
time.sleep(1)
WestYellow.off()
WestGreen.on()
time.sleep(2)
WestGreen.off()
WestRed.on()
time.sleep(1)
NorthRed.off()
NorthYellow.on()
time.sleep(1)
NorthYellow.off()
NorthGreen.on()
time.sleep(2)
NorthGreen.off()
NorthRed.on()
time.sleep(1)
SouthRed.off()
SouthYellow.on()
time.sleep(1)
SouthYellow.off()
SouthGreen.on()
time.sleep(2)
SouthGreen.off()
SouthRed.on()
time.sleep(1)
except KeyboardInterrupt:
PiTraffic.closeGPIO()