Music Controlled Raspberry Pi Lights Change Color by Playing Piano

Raspberry Pi
(Image credit: RandomBrasilian)

Raspberry Pi projects don’t have to be complex to be incredible and this Pi project is a shining example. RandomBrasilian has created a Raspberry Pi Zero-powered set of Christmas lights that react to different musical notes played on a keyboard. According to the original post shared to Reddit, this was their first Pi project ever making the creation that much more impressive.

my_first_pi_project_digital_piano_pi_zero_xmas from r/raspberry_pi

The idea was to create a system that would change the colors of LEDs as music is played on a digital piano. RandomBrasilian is using string of addressable WS2811 lights that one at a time change color down the string as notes are played. Each note corresponds with a color, creating a visual display of the music you just heard.

In our experience, some of the best Raspberry Pi projects have a few iterations before reaching their final design. We reached out to RandomBrasilian who explained that a prototype was created using Philips Hue lights connected to their computer. But to make things more dynamic, they decided to use WS2811 Christmas lights and to power the project with a Raspberry Pi Zero instead of a PC.

The keyboard outputs data to the Pi via USB in the form of MIDI. This input is read using Mido lib, a Python library created for working with MIDI input. As each note is recognized, the next light in the string changes to a predetermined corresponding color. Another concept that failed to make it to the final product was the idea to illuminate a light only while the note is played but as only one light shows at a time, this proved to be much less dazzling.

Check out the original thread from Reddit for a demo video of these lights in action and be sure to follow RandomBrasilian for updates on this exciting Pi project.

Ash Hill
Freelance News and Features Writer

Ash Hill is a Freelance News and Features Writer at Tom's Hardware US. She manages the Pi projects of the month and much of our daily Raspberry Pi reporting.