Marius Schueller

Building a Custom Animation Display
1/31/2025
I programmed a light board to play any animation I want whenever I want. Here’s how I did it.
What I used
RGB LED Matrix (32x32)
Raspberry Pi 3
Adafruit RGB Matrix Bonnet
Power cords (Raspberry Pi 3, Adafruit RGB Matrix Bonnet)
Getting a visualization
I started by working on the programming. Knowing that my end goal was
getting my own animations to play, I wanted to get data from an image.
What data? Well, I need to know what color to display on the lights on
the board. The board is an RGB matrix meaning the colors shown are
represented by the amount of red, green, and blue (RGB) present. Lucky
for us, the color of pixels in photos can be represented by the RGB
amounts present. If we have a 1280 x 720 image, we have 921,600 pixels,
each with RGB values.
Sizing
The next issue we get is that our board is only 32x32, so the resolution of images has to be decreased to this point. I chose to take the average color of 1/32 of the original image for every row and column.
Visualization
To check if things worked, I visualized the data I was getting. I used the matplotlib library to create a graph with x and y values from 0-32 and then colored each point by its RGB value.Videos
Videos weren’t too hard from there, because a video is simply a series of images played in rapid succession. I wrote some code that would get every frame of a video and then apply the aforementioned photo transformations. I then visualized everything using a delay of 0.05 seconds (20fps). This is very handy because I could see how things would look before putting them on the board.Storing and Accessing Data
I need to be able to store this data for future use. There are definitely
more efficient encoding methods, but for simplicity, I used a JSON format.
Every video is grouped, containing elements of every frame. Every frame
has 1024 elements for pixels (32 x 32), and every pixel has 3 elements
representing RGB values.
So, for me, there was a question of where to store the animation JSON data.
I considered storing the animations on the Raspberry Pi, but that would
mean reprogramming the board every time I want to change the animations.
That limits the flexibility, so I decided that an API would be the best.
An API is an application from which I can receive information. I’ve done
a couple of projects in the past where I created APIs using Flask. I
initially programmed the API to give back a random animation. I hosted
this API on Vercel because it’s free and pretty straightforward. I wanted
my final product to play certain things on certain days like holidays and
birthdays. So, I used the datetime library in Python and added some
conditions for playing things at certain times.
Working Board!!!
Now comes the scariest part for me. I did all of this programming while
I was waiting for a power chord to arrive so I had no idea how things
would work.
Coding
I forked rpi-rgb-led-matrix library which is made for LED matrices. I know Adafruit has a fork of the library, but their library hasn’t been updated in 8 years and is 829 commits behind the main repository, so I felt a little more comfortable using the main repository. After forking, I added in my files and used their samples to see how to create my own script.Environment Setup
Putting things on the Raspberry Pi was a little annoying. To start, I cloned my repository to the board. I followed the instructions in the repository to set things up. I first tested one of their samples, and it was so cool to see it work. Then I tried to run my programs. Because pip isn’t a thing in Raspberry Pi boards, I added the necessary libraries by using sudo apt install.Success
After some reworking of my code, I experienced the pure joy that comes with seeing the result of hours and hours of hard work come together. Seeing the animation play for the first time was incredible.Moving Forward
Feel free to look at my code that I have linked at the bottom of the page.
This project is now pretty much done, but I will occasionally add
animations here and there and program in more holidays. When my
favorite sports teams win, I can have it show something in
celebration. It's just so cool to have around!
- Marius