Skip to content

Adding status single-NeoPixel template examples. #1521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CircuitPython_Templates/status_led_one_neopixel_rainbow.py
Original file line number Diff line number Diff line change
@@ -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(delay):
for color_value in range(255):
for pixels in range(1):
pixel_index = (pixels * 256 // 1) + color_value
pixel[pixels] = colorwheel(pixel_index & 255)
pixel.show()
time.sleep(delay)


while True:
rainbow(0.02)
16 changes: 16 additions & 0 deletions CircuitPython_Templates/status_led_one_neopixel_rgb.py
Original file line number Diff line number Diff line change
@@ -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)