-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
64 lines (54 loc) · 1.73 KB
/
Copy pathcode.py
File metadata and controls
64 lines (54 loc) · 1.73 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
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
# Circuit Playground NeoPixel
import time
import board
from rainbowio import colorwheel
import neopixel
import adafruit_fancyled.adafruit_fancyled as fancy
pixels_circuit = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.1, auto_write=False)
pixels_neo = neopixel.NeoPixel(board.A2, 60, brightness=1, auto_write=False, pixel_order=neopixel.RGBW)
RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
WHITE = (255, 255, 255)
OFF = (0, 0, 0)
def rainbow_cycle(wait, pixels):
for j in range(255):
for i in range(len(pixels)):
rc_index = (i * 256 // 10) + j * 5
pixels[i] = colorwheel(rc_index & 255)
pixels.show()
time.sleep(wait)
def color_chase(color, wait, pixels):
for i in range(len(pixels)):
pixels[i] = color
pixels[round(i/6)] = color
time.sleep(wait)
pixels.show()
pixel.show()
time.sleep(0.5)
def color_chase_demo(pixels):
color_chase(RED, 0.1, pixels) # Increase the number to slow down the color chase
color_chase(YELLOW, 0.1, pixels)
color_chase(GREEN, 0.1, pixels)
color_chase(CYAN, 0.1, pixels)
color_chase(BLUE, 0.1, pixels)
color_chase(PURPLE, 0.1, pixels)
color_chase(OFF, 0.1, pixels)
def rainbow(wait, pixels):
for j in range(255):
for i in range(len(pixels)):
idx = int(i + j)
pixels[i] = colorwheel(idx & 255)
pixels.show()
time.sleep(wait)
for i in range(len(pixels)):
idx = int(i + j)
pixels[i] = colorwheel(idx & 255)
pixels.show()
time.sleep(wait)
while True:
#rainbow_cycle(0.03, pixels_circuit)
rainbow(0.03, pixels_neo)