-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.py
46 lines (35 loc) · 881 Bytes
/
code.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
# Get signal from a button
# One pole to 3.3V and one to a GPIO pin
import board
import time
import digitalio
import board
import neopixel
from ledPixelsPico import *
# Chnage number of LEDs here
nPix = 18
# Defines state of LEDs
def turnon():
for i in range (nPix):
pixels[i] = (220, 220, 190)
def turnoff():
for i in range (nPix):
pixels[i] = (0, 0, 0)
# Change GPIO for LEDs
pixels = neopixel.NeoPixel(board.GP13, nPix)
# Change GPIO for button here
timerBtn = digitalio.DigitalInOut(board.GP28)
timerBtn.pull = digitalio.Pull.DOWN
mode="off"
#Controls how switch behaves
while True:
if timerBtn.value:
while timerBtn.value:
time.sleep(0.1)
if mode == "off":
mode="on"
turnon()
else:
mode="off"
turnoff()
print("mode:", mode)