]> vault307.fbx.one Git - Sensory_Wall.git/blob - redlight.py
more sensory wall projects
[Sensory_Wall.git] / redlight.py
1 from machine import Pin
2 import time, random
3
4 green=Pin(17,Pin.OUT)
5 yellow=Pin(14,Pin.OUT)
6 red=Pin(15,Pin.OUT)
7
8 leds=[green,yellow,red]
9 global count
10 count=0
11
12 manPin=Pin(18,Pin.IN,Pin.PULL_UP)
13 button=Pin(16,Pin.IN,Pin.PULL_UP)
14
15 green.on()
16 yellow.off()
17 red.off()
18
19 def button_handler():
20 if button.value()==0:
21 global count
22 leds[count].off()
23 print(count)
24 count=count+1
25 if count==3:
26 count=0
27 leds[count].on()
28 return count
29
30 def rand_handler():
31 global count
32 leds[count].off()
33 print(count)
34 count=count+1
35 if count==3:
36 count=0
37 leds[count].on()
38 return count
39
40 while True:
41 if manPin.value()==1:
42 button_handler()
43 time.sleep(0.5)
44 else:
45 rand_handler()
46 time.sleep(random.randint(3,15))
47