Skip to content

Commit d23d362

Browse files
authored
Add NeoPixel control script for Crickit FeatherWing
This script drives NeoPixels on the Crickit FeatherWing, implementing color fill, color chase, and rainbow cycle effects.
1 parent af78790 commit d23d362

File tree

1 file changed

+60
-0
lines changed
  • Crickits/Make_It_Glow_With_Crickit/Crickit-Feather-NeoPixels

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
# Drive NeoPixels on the NeoPixels Block on Crickit FeatherWing
6+
import time
7+
from rainbowio import colorwheel
8+
from adafruit_crickit import crickit
9+
from adafruit_seesaw.neopixel import NeoPixel
10+
11+
num_pixels = 30 # Number of pixels driven from Crickit NeoPixel terminal
12+
13+
# The following line sets up a NeoPixel strip on Seesaw pin 20 for Feather
14+
pixels = NeoPixel(crickit.seesaw, 20, num_pixels)
15+
16+
def color_chase(color, wait):
17+
for i in range(num_pixels):
18+
pixels[i] = color
19+
time.sleep(wait)
20+
pixels.show()
21+
time.sleep(0.5)
22+
23+
def rainbow_cycle(wait):
24+
for j in range(255):
25+
for i in range(num_pixels):
26+
rc_index = (i * 256 // num_pixels) + j
27+
pixels[i] = colorwheel(rc_index & 255)
28+
pixels.show()
29+
time.sleep(wait)
30+
31+
RED = (255, 0, 0)
32+
YELLOW = (255, 150, 0)
33+
GREEN = (0, 255, 0)
34+
CYAN = (0, 255, 255)
35+
BLUE = (0, 0, 255)
36+
PURPLE = (180, 0, 255)
37+
38+
while True:
39+
print("fill")
40+
pixels.fill(RED)
41+
pixels.show()
42+
# Increase or decrease to change the speed of the solid color change.
43+
time.sleep(1)
44+
pixels.fill(GREEN)
45+
pixels.show()
46+
time.sleep(1)
47+
pixels.fill(BLUE)
48+
pixels.show()
49+
time.sleep(1)
50+
51+
print("chase")
52+
color_chase(RED, 0.1) # Increase the number to slow down the color chase
53+
color_chase(YELLOW, 0.1)
54+
color_chase(GREEN, 0.1)
55+
color_chase(CYAN, 0.1)
56+
color_chase(BLUE, 0.1)
57+
color_chase(PURPLE, 0.1)
58+
59+
print("rainbow")
60+
rainbow_cycle(0) # Increase the number to slow down the rainbow

0 commit comments

Comments
 (0)