-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
53 lines (48 loc) · 1.43 KB
/
main.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
### This is the script powering trisight halloween costume, running on Adafruit GEMMA M0 running CircuitPython
import board
import neopixel
import time
try:
import urandom as random # for v1.0 API support
except ImportError:
import random
numpix = 21 # Number of NeoPixels
pixpin = board.D1 # Pin where NeoPixels are connected
strip = neopixel.NeoPixel(pixpin, numpix)
alpha = 0.1
c_white = (255, 255, 255)
c_red = (255, 0, 0)
c_black = (0, 0, 0)
strip.brightness = alpha
def render(strip, data):
strip.fill([0,0,0])
for i in range(len(data)):
strip[i] = data[i]
frames = [
[
c_white,c_white,c_red,c_black,c_white,c_black,c_black,
c_white,c_black,c_red,c_white,c_black,c_black,c_white,
c_white,c_white,c_black,c_white,c_black,c_white,c_black
],
[
c_white,c_white,(50,0,0),c_black,c_white,c_black,c_black,
c_white,c_black,(50,0,0),c_white,c_black,c_black,c_white,
c_white,c_white,c_black,c_white,c_black,c_white,c_black
],
[
c_white,c_white,c_black,c_black,c_white,c_black,c_black,
c_white,c_black,c_black,c_white,c_black,c_black,c_white,
c_white,c_white,c_black,c_white,c_black,c_white,c_black
],
[
c_white,c_white,(50,0,0),c_black,c_white,c_black,c_black,
c_white,c_black,(50,0,0),c_white,c_black,c_black,c_white,
c_white,c_white,c_black,c_white,c_black,c_white,c_black
],
]
step = 0
while True: # Loop forever...
render(strip, frames[step])
strip.write()
step = (step + 1) % len(frames)
time.sleep(0.16)