The code in this guide is compatible with CircuitPython 9.2 and later, including 9.2.0-rc.0.
Click on the Download Project Bundle button in the window below. It will download to your computer as a zipped folder.
# SPDX-FileCopyrightText: Copyright (c) 2024 Jeff Epler for Adafruit Industries # # SPDX-License-Identifier: Unlicense import board import rainbowio import supervisor from adafruit_led_animation.animation.rainbow import Rainbow from adafruit_led_animation.animation.rainbowchase import RainbowChase from adafruit_led_animation.animation.rainbowcomet import RainbowComet from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle from adafruit_led_animation.sequence import AnimationSequence from adafruit_tm1814 import TM1814PixelBackground # The pin where the LED strip data line is connected TM1814 = board.A0 # The number of TM1814 controllers. Note that sometimes one "pixel" controls # more than one LED package. # # One common configuration is 3 LED packages & 1 controller per 50mm, giving # 100 TM1814 controllers (300 LED packages) in 5 meters of LED strip. NUM_PIXELS = 100 pixels = TM1814PixelBackground(TM1814, NUM_PIXELS, brightness=0.1) # Perform a rainbow animation sequence rainbow = Rainbow(pixels, speed=0.1, period=2) rainbow_chase = RainbowChase(pixels, speed=0.1, size=5, spacing=3) rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True) rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15) animations = AnimationSequence( rainbow, rainbow_chase, rainbow_comet, rainbow_sparkle, advance_interval=5, auto_clear=True, ) while True: animations.animate()
Copy the code to your CircuitPython device
After downloading the Project Bundle, plug your CircuitPython device into the computer's USB port with a known good USB data+power cable. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called CIRCUITPY. Open up the zipped file, go to the the appropriate folder inside (e.g., CircuitPython 9.x if you are using CircuitPython 9.x) and copy the items in that folder directly onto your CIRCUITPY drive.
Your CIRCUITPY drive should look like this after copying the sound effects and the code.py file.

Wiring the TM1814 LED strip
Refer to manufacturer instructions to identify the connections & connectors on your TM1814 LED strip.
Make the following connections:
- TM1814 power and GND to dedicated power supply according to manufacturer directions (e.g., 12VDC 2A)
- TM1814 GND to microcontroller GND
- TM1814 Data In to microcontroller A0 (GP26 on Pico / Pico 2)
Do not connect TM1814 power to microcontroller power, as this will damage the microcontroller.
import board import rainbowio import supervisor from adafruit_led_animation.animation.rainbow import Rainbow from adafruit_led_animation.animation.rainbowchase import RainbowChase from adafruit_led_animation.animation.rainbowcomet import RainbowComet from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle from adafruit_led_animation.sequence import AnimationSequence from adafruit_tm1814 import TM1814PixelBackground
The next section supports some customization: you can change the pin connected to the TM1814 data line, and customize the number of pixels.
# The pin where the LED strip data line is connected TM1814 = board.A0 # The number of TM1814 controllers. Note that sometimes one "pixel" controls # more than one LED package. # # One common configuration is 3 LED packages & 1 # controller per 50mm, giving 100 TM1814 controllers (300 LED packages) in 5 # meters of LED strip. NUM_PIXELS = 100
A TM1814 LED strip is initialized and set to all black with this line:
pixels = TM1814PixelBackground(TM1814, NUM_PIXELS, brightness=0.1)
Then the code creates a series of animations (as detailed in the guide for theĀ Adafruit LED Animation library) and runs the animations forever:
# Perform a rainbow animation sequence rainbow = Rainbow(pixels, speed=0.1, period=2) rainbow_chase = RainbowChase(pixels, speed=0.1, size=5, spacing=3) rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True) rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15) animations = AnimationSequence( rainbow, rainbow_chase, rainbow_comet, rainbow_sparkle, advance_interval=5, auto_clear=True, ) while True: animations.animate()
Page last edited January 22, 2025
Text editor powered by tinymce.