Adding status NeoPixel template examples

This commit is contained in:
Kattni Rembor 2021-04-21 18:31:06 -04:00
parent 5d5270811e
commit e3078c9383
2 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1,31 @@
"""
CircuitPython status NeoPixel rainbow example.
Update PIXELBUF_VERSION to _pixelbuf if available for the board (this is the most common case!)
or to adafruit_pypixelbuf where necessary (typically non-Express SAMD21 M0 boards).
For example:
If you are using a QT Py RP2040, change PIXELBUF_VERSION to _pixelbuf.
If you are using a QT Py M0, change PIXELBUF_VERSION to adafruit_pypixelbuf.
"""
import time
import board
import neopixel
from PIXELBUF_VERSION import colorwheel
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, auto_write=False)
pixel.brightness = 0.3
def rainbow(speed):
for j in range(255):
for i in range(1):
pixel_index = (i * 256 // 1) + j
pixel[i] = colorwheel(pixel_index & 255)
pixel.show()
time.sleep(speed)
while True:
rainbow(0.02)

View file

@ -0,0 +1,16 @@
"""CircuitPython status NeoPixel red, green, blue example."""
import time
import board
import neopixel
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
pixel.brightness = 0.3
while True:
pixel.fill((255, 0, 0))
time.sleep(0.5)
pixel.fill((0, 255, 0))
time.sleep(0.5)
pixel.fill((0, 0, 255))
time.sleep(0.5)