The code in this guide is compatible with CircuitPython 9.2 and later, including 9.2.0-rc.0.
CircuitPython simpletest
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_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) # Cycle the rainbow at about 1 cycle every 4 seconds while True: pixels.fill(rainbowio.colorwheel(supervisor.ticks_ms() // 16))
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.

import board import rainbowio import supervisor 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)
The code's forever loop just sets the whole strip's color to a rainbow color in a pattern that repeats about every 4 seconds:
# Cycle the rainbow at about 1 cycle every 4 seconds while True: pixels.fill(rainbowio.colorwheel(supervisor.ticks_ms() // 16))
Page last edited January 22, 2025
Text editor powered by tinymce.