The main use of the Sparkle Motion Mini is lighting up RGB LEDs to dazzle and delight. CircuitPython has the Adafruit_CircuitPython_Neopixel module, which allows you to easily write Python code that lets you control NeoPixels, as well as the Adafruit_CircuitPython_LED_Animation module that provides more advanced control with an assortment of fun and colorful animations. In the example below, you'll run two different LED animations on two strips of NeoPixels at the same time.Â
NeoPixels
- terminal block G to GND on both NeoPixel strips. (black wire, going through breadboard GND rail)
- terminal block 5VÂ to 5V on both NeoPixel strips. (red wire, going through breadboard power rail)
- terminal block 33 to DIN on the first NeoPixel strip. (green wire)
- terminal block 32 to DIN on the second NeoPixel strip. (green wire)
CircuitPython Usage
To use with CircuitPython, you need to first install a few libraries, into the lib folder on your board. Then you need to update code.py with the example script.
In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, open the directory Sparkle_Motion_Mini_Examples/CircuitPython_Sparkle_Motion_Mini_Neopixel_Animation/ and then click on the directory that matches the version of CircuitPython you're using.
# SPDX-FileCopyrightText: 2025 Tim Cocks for Adafruit Industries # # SPDX-License-Identifier: MIT """ Example illustrating two different LED Animations running on Neopixels connected to the 2 main outputs of the Sparkle Motion Mini """ import board import neopixel from adafruit_led_animation.animation.comet import Comet from adafruit_led_animation.animation.rainbow import Rainbow from adafruit_led_animation.color import GREEN strip1_pixel_pin = board.D33 strip2_pixel_pin = board.D32 pixel_count = 8 strip1_pixels = neopixel.NeoPixel( strip1_pixel_pin, pixel_count, brightness=0.1, auto_write=False ) strip2_pixels = neopixel.NeoPixel( strip2_pixel_pin, pixel_count, brightness=0.05, auto_write=False ) comet = Comet(strip1_pixels, speed=0.05, color=GREEN, tail_length=3, bounce=True) rainbow = Rainbow(strip2_pixels, speed=0.05, period=3) while True: comet.animate() rainbow.animate()
In the editor window in your browser, click the Open button to view the file dialog. Then, click the Upload button and select Upload Folders.
After the upload finishes, you can open the lib folder to view the two library files required for the NeoPixel examples.
Your CIRCUITPY/lib folder should contain the following folders:
- adafruit_led_animation/
- adafruit_pixelbuf.mpy
- neopixel.mpy
In the editor window in your browser, click the Open button to view the file dialog. Then, click the Upload button and select Upload Files.
You'll be asked if you want to overwrite the previous code.py with the new code.py file from the Project Bundle. Click OK.
This example utilizes both of the NeoPixel outputs on terminal blocks D33
and D32
. It starts by initializing variables for the pixel pins and count of how many NeoPixels are in each strip. Next it creates instances of neopixel.NeoPixel
for each strip. Then it creates a Comet
animation on one strip, and a Rainbow
animation on the other. Inside of the main while True:
each animation object has it's animate()
function called to advance it by one step.
Page last edited January 24, 2025
Text editor powered by tinymce.