-
Notifications
You must be signed in to change notification settings - Fork 0
/
light.py
135 lines (130 loc) · 4.46 KB
/
light.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import RPi.GPIO as GPIO
#useless edit so I can push again
red_front = 16
green_front = 20
blue_front = 27
red_back = 22
green_back = 21
blue_back = 17
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(red_back,GPIO.OUT)
GPIO.setup(green_back,GPIO.OUT)
GPIO.setup(blue_back,GPIO.OUT)
GPIO.setup(red_front,GPIO.OUT)
GPIO.setup(green_front,GPIO.OUT)
GPIO.setup(blue_front,GPIO.OUT)
def setup():
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(red_back,GPIO.OUT)
GPIO.setup(green_back,GPIO.OUT)
GPIO.setup(blue_back,GPIO.OUT)
GPIO.setup(red_front,GPIO.OUT)
GPIO.setup(green_front,GPIO.OUT)
GPIO.setup(blue_front,GPIO.OUT)
#color functions----------------------------------------
def white(red,blue,green):
GPIO.output(red,GPIO.HIGH)
GPIO.output(blue,GPIO.HIGH)
GPIO.output(green,GPIO.HIGH)
def red(red,blue,green):
GPIO.output(red,GPIO.HIGH)
GPIO.output(blue,GPIO.LOW)
GPIO.output(green,GPIO.LOW)
def blue(red,blue,green):
GPIO.output(red,GPIO.LOW)
GPIO.output(green,GPIO.LOW)
GPIO.output(blue,GPIO.HIGH)
def green(red,blue,green):
GPIO.output(red,GPIO.LOW)
GPIO.output(green,GPIO.HIGH)
GPIO.output(blue,GPIO.LOW)
def yellow(red,blue,green):
GPIO.output(red,GPIO.HIGH)
GPIO.output(green,GPIO.HIGH)
GPIO.output(blue,GPIO.LOW)
def purple(red,blue,green):
GPIO.output(red,GPIO.HIGH)
GPIO.output(green,GPIO.LOW)
GPIO.output(blue,GPIO.HIGH)
def teal(red,blue,green):
GPIO.output(red,GPIO.LOW)
GPIO.output(green,GPIO.HIGH)
GPIO.output(blue,GPIO.HIGH)
#----------------------------------------------------
#-----------turn off lights function
def off(location):
setup()
if location == "FRONT LIGHTS":
red_off = red_front
blue_off = blue_front
green_off = green_front
if location == "BACK LIGHTS":
red_off = red_back
blue_off = blue_back
green_off = green_back
if location == "BOTH LIGHTS":
GPIO.output(red_front, GPIO.LOW)
GPIO.output(green_front, GPIO.LOW)
GPIO.output(blue_front, GPIO.LOW)
red_off = red_back
blue_off = blue_back
green_off = green_back
GPIO.output(red_off, GPIO.LOW)
GPIO.output(green_off,GPIO.LOW)
GPIO.output(blue_off,GPIO.LOW)
#----------set color fucntion
def set(location, color):
if location == "FRONT LIGHTS":
if color == "red":
red(red_front, blue_front, green_front)
elif color == "blue":
blue(red_front, blue_front, green_front)
elif color == "green":
green(red_front, blue_front, green_front)
elif color == "purple":
purple(red_front, blue_front, green_front)
elif color == "white":
white(red_front, blue_front, green_front)
elif color == "yellow":
yellow(red_front, blue_front, green_front)
elif color == "teal":
teal(red_front, blue_front, green_front)
elif location == "BACK LIGHTS":
if color == "red":
red(red_back, blue_back, green_back)
elif color == "blue":
blue(red_back, blue_back, green_back)
elif color == "green":
green(red_back, blue_back, green_back)
elif color == "purple":
purple(red_back, blue_back, green_back)
elif color == "white":
white(red_back, blue_back, green_back)
elif color == "yellow":
yellow(red_back, blue_back, green_back)
elif color == "teal":
teal(red_back, blue_back, green_back)
elif location == "BOTH LIGHTS":
if color == "red":
red(red_front, blue_front, green_front)
red(red_back, blue_back, green_back)
elif color == "blue":
blue(red_front, blue_front, green_front)
blue(red_back, blue_back, green_back)
elif color == "green":
green(red_front, blue_front, green_front)
green(red_back, blue_back, green_back)
elif color == "purple":
purple(red_front, blue_front, green_front)
purple(red_back, blue_back, green_back)
elif color == "white":
white(red_front, blue_front, green_front)
white(red_back, blue_back, green_back)
elif color == "yellow":
yellow(red_front, blue_front, green_front)
yellow(red_back, blue_back, green_back)
elif color == "teal":
teal(red_front, blue_front, green_front)
teal(red_back, blue_back, green_back)