The LED Animation library is designed to make displaying LED animations super simple. The first thing you need to do is import the necessary modules from the LED Animation library and create your initial pixel object. Each animation is a separate module to ensure you only import exactly what you need.

CircuitPython LED Animation Library

To get the necessary libraries for this guide, download the latest CircuitPython library bundle from

Open the downloaded zip and find the following folder and file within the lib folder:

  • adafruit_led_animation
  • neopixel.mpy

Drag this folder and file to the lib folder on your CIRCUITPY drive.

Import and Setup

The rest of the guide will reference this page. When you are introduced to each animation, the code snippet will not include the entire setup found below. It is assumed that you have included the rest of the import and setup necessary to make the code run. If you find an example is not working, make sure you've included the entire import and setup found on this page.

An example of import and setup for the NeoPixel FeatherWing is as follows:

import board
import neopixel
from adafruit_led_animation.animation.solid import Solid
from adafruit_led_animation.color import RED

pixel_pin = board.D6
pixel_num = 32

pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.2, auto_write=False)

First you import board and neopixel. Next, you import the Solid module and the color RED.

Next you identify the pin to which you've connected to your NeoPixels, board.D6 in this case, and the number of pixels connected, 32. This example uses the NeoPixel FeatherWing. If you're using some other NeoPixel form factor, you would change these variables to match the pin you chose and the number of pixels you connected.

Finally, you create the pixel object.

This guide will use NeoPixels for all the examples, but the LED Animation library works equally well with DotStar LEDs. If you are using DotStars, you'll need to load the adafruit_dotstar.mpy file onto your CIRCUITPY drive. As well, your import and setup will differ in your code.

For example:

import board
import adafruit_dotstar
from adafruit_led_animation.animation.solid import Solid
from adafruit_led_animation.color import RED

clock_pin = board.D12
data_pin = board.D11
pixel_num = 144

pixels = adafruit_dotstar.DotStar(clock_pin, data_pin, num_pixels,
                                  brightness=0.2, auto_write=False)

This example imports the necessary modules and assigns the appropriate pins and number of pixels to use 144 DotStar LEDs connected to D12 and D11.

These are very basic examples of what your import and setup may look like. It will likely end up far more complicated than that as you begin to work with multiple animations and so on. Regardless, this gives you an idea of what to expect. Now it's time to start animating!

This guide was first published on May 27, 2020. It was last updated on Jul 15, 2024.

This page (Import and Setup) was last updated on Mar 08, 2024.

Text editor powered by tinymce.