Skip to content

Commit 20af800

Browse files
authored
Merge pull request adafruit#1235 from firepixie/master
Wire Wrap Necklace Code
2 parents 8213cf6 + 4cf4a9e commit 20af800

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

Wire_Wrap_Necklace/code.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
"""
2+
FancyLED Necklace Insert Code
3+
Written by Phil Burgess and Erin St Blaine for Adafruit Industries
4+
Full tutorial: https://learn.adafruit.com/neopixel-led-necklace-insert-with-usb-charging
5+
6+
"""
7+
8+
import board
9+
import neopixel
10+
import adafruit_fancyled.adafruit_fancyled as fancy
11+
12+
NUM_LEDS = 15
13+
14+
# Define your palettes. Add as many colors as you like.
15+
# You can use CRGB, CHSV or Hex format, or any combination therein
16+
# Select which palette you're using below the palette definitions
17+
18+
palette_fire = [fancy.CRGB(0, 0, 0), #Black
19+
fancy.CHSV(1.0), #Red
20+
fancy.CRGB(1.0, 1.0, 0.0), #Yellow
21+
0xFFFFFF,] #White
22+
23+
24+
palette_water = [fancy.CRGB(0, 214, 214), # blues and cyans
25+
fancy.CRGB(0, 92, 160),
26+
fancy.CRGB(0, 123, 255),
27+
fancy.CRGB(0, 100, 200),
28+
fancy.CRGB(0, 120, 210),
29+
fancy.CRGB(0, 123, 255),
30+
fancy.CRGB(0, 68, 214),
31+
fancy.CRGB(0, 68, 214),
32+
fancy.CRGB(0, 28, 214),
33+
fancy.CRGB(0, 68, 200),
34+
fancy.CRGB(0, 68, 214),
35+
fancy.CRGB(0, 200, 50),
36+
fancy.CRGB(0, 200, 80),
37+
fancy.CRGB(0, 200, 20),
38+
fancy.CRGB(0, 100, 50),
39+
fancy.CRGB(0, 150, 50),]
40+
41+
palette_forest = [0xa6db97,
42+
0xc6de50,
43+
0x2a7a02,
44+
0x5fb862,
45+
0x314a32,
46+
0xd5e8d6,]
47+
48+
palette_cloud = [fancy.CHSV(0.8, 1.0, 1.0),
49+
fancy.CHSV(0.6, 0.8, 0.7),
50+
fancy.CHSV(0.7, 1.0, 0.8),]
51+
52+
#choose your active palette
53+
palette = palette_water
54+
55+
# Declare a NeoPixel object on pin A1 with NUM_LEDS pixels, no auto-write.
56+
# Set brightness to max because we'll be using FancyLED's brightness control.
57+
pixels = neopixel.NeoPixel(board.A1, NUM_LEDS, brightness=1.0,
58+
auto_write=False)
59+
60+
OFFSET = 0 # Positional offset into color palette to get it to 'spin'
61+
62+
while True:
63+
for i in range(NUM_LEDS):
64+
# Load each pixel's color from the palette using an offset, run it
65+
# through the gamma function, pack RGB value and assign to pixel.
66+
color = fancy.palette_lookup(palette, OFFSET + i / NUM_LEDS)
67+
color = fancy.gamma_adjust(color, brightness=0.25)
68+
pixels[i] = color.pack()
69+
pixels.show()
70+
71+
OFFSET += 0.005 # Bigger number = faster spin

0 commit comments

Comments
 (0)