-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlights.py
More file actions
39 lines (32 loc) · 1.13 KB
/
Copy pathlights.py
File metadata and controls
39 lines (32 loc) · 1.13 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
from gpiozero import LED
from time import sleep
def setup():
PIN_MAPPING = {
'red': [2, 17, 0, 16],
'yellow': [3, 27, 5, 20],
'green': [4, 22, 6, 21]
}
global leds
leds = {color: [LED(pin) for pin in pins] for color, pins in PIN_MAPPING.items()}
for led in leds['red']:
led.on()
print("Setup complete")
return leds
def light_on(index):
# Assuming index is 1-based and maps to a 1-based group of LEDs
group = [leds['red'][index-1], leds['yellow'][index-1], leds['green'][index-1]]
group[0].off() # Turn off red light
group[1].on() # Turn on yellow light
sleep(1)
group[1].off() # Turn off yellow light
group[2].on() # Turn on green light
def wait(duration):
sleep(duration)
def light_off(index):
# Assuming index is 1-based and maps to a 1-based group of LEDs
group = [leds['red'][index-1], leds['yellow'][index-1], leds['green'][index-1]]
group[2].off() # Turn off green light
group[1].on() # Turn on yellow light
sleep(2)
group[1].off() # Turn off yellow light
group[0].on() # Turn on red light