Adding status NeoPixel template examples
This commit is contained in:
parent
5d5270811e
commit
e3078c9383
2 changed files with 47 additions and 0 deletions
31
CircuitPython_Templates/status_led_one_neopixel_rainbow.py
Normal file
31
CircuitPython_Templates/status_led_one_neopixel_rainbow.py
Normal 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)
|
||||
16
CircuitPython_Templates/status_led_one_neopixel_rgb.py
Normal file
16
CircuitPython_Templates/status_led_one_neopixel_rgb.py
Normal 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)
|
||||
Loading…
Reference in a new issue