Skip to content

Commit 87a9ced

Browse files
authored
Merge pull request #864 from adafruit/TheKitty-patch-104
Add tutorial code per basecamp
2 parents 5ecf741 + 5745354 commit 87a9ced

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Glowing_Scale_Armor/code.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
""" Simple FancyLED example for NeoPixel strip
2+
"""
3+
4+
import board
5+
import neopixel
6+
import adafruit_fancyled.adafruit_fancyled as fancy
7+
8+
num_leds = 17
9+
10+
# Declare a Water Colors palette
11+
palette = [fancy.CRGB(0, 214, 214), # blues and cyans
12+
fancy.CRGB(0, 92, 160),
13+
fancy.CRGB(0, 123, 255),
14+
fancy.CRGB(0, 68, 214)]
15+
16+
# Declare a Fire Colors palette
17+
#palette = [fancy.CRGB(0, 0, 0), # Black
18+
# fancy.CHSV(1.0), # Red
19+
# fancy.CRGB(1.0, 1.0, 0.0), # Yellow
20+
# 0xFFFFFF] # White
21+
22+
# Declare a NeoPixel object on pin D6 with num_leds pixels, no auto-write.
23+
# Set brightness to max because we'll be using FancyLED's brightness control.
24+
pixels = neopixel.NeoPixel(board.D1, num_leds, brightness=1.0,
25+
auto_write=False)
26+
27+
offset = 0 # Positional offset into color palette to get it to 'spin'
28+
29+
while True:
30+
for i in range(num_leds):
31+
# Load each pixel's color from the palette using an offset, run it
32+
# through the gamma function, pack RGB value and assign to pixel.
33+
color = fancy.palette_lookup(palette, offset + i / num_leds)
34+
color = fancy.gamma_adjust(color, brightness=0.25)
35+
pixels[i] = color.pack()
36+
pixels.show()
37+
38+
offset += 0.02 # Bigger number = faster spin

0 commit comments

Comments
 (0)