Skip to content

Commit e3078c9

Browse files
committed
Adding status NeoPixel template examples
1 parent 5d52708 commit e3078c9

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(speed):
22+
for j in range(255):
23+
for i in range(1):
24+
pixel_index = (i * 256 // 1) + j
25+
pixel[i] = colorwheel(pixel_index & 255)
26+
pixel.show()
27+
time.sleep(speed)
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)