Skip to content

Commit 4a66208

Browse files
authored
Merge pull request #1521 from kattni/template-status-neopixel
Adding status single-NeoPixel template examples.
2 parents 5d52708 + ccf87e8 commit 4a66208

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
CircuitPython status NeoPixel rainbow example.
3+
4+
Update PIXELBUF_VERSION to _pixelbuf if available for the board (this is the most common case!)
5+
or to adafruit_pypixelbuf where necessary (typically non-Express SAMD21 M0 boards).
6+
7+
For example:
8+
If you are using a QT Py RP2040, change PIXELBUF_VERSION to _pixelbuf.
9+
If you are using a QT Py M0, change PIXELBUF_VERSION to adafruit_pypixelbuf.
10+
"""
11+
import time
12+
import board
13+
import neopixel
14+
from PIXELBUF_VERSION import colorwheel
15+
16+
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, auto_write=False)
17+
18+
pixel.brightness = 0.3
19+
20+
21+
def rainbow(delay):
22+
for color_value in range(255):
23+
for pixels in range(1):
24+
pixel_index = (pixels * 256 // 1) + color_value
25+
pixel[pixels] = colorwheel(pixel_index & 255)
26+
pixel.show()
27+
time.sleep(delay)
28+
29+
30+
while True:
31+
rainbow(0.02)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""CircuitPython status NeoPixel red, green, blue example."""
2+
import time
3+
import board
4+
import neopixel
5+
6+
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
7+
8+
pixel.brightness = 0.3
9+
10+
while True:
11+
pixel.fill((255, 0, 0))
12+
time.sleep(0.5)
13+
pixel.fill((0, 255, 0))
14+
time.sleep(0.5)
15+
pixel.fill((0, 0, 255))
16+
time.sleep(0.5)

0 commit comments

Comments
 (0)