This piano controls an LED rainbow with Raspberry Pi Zero
With a Raspberry Pi Zero, an affordable strip of lights, and an electric piano, musicians can create an LED rainbow from the notes they play.
How does it work?
When the piano is played, it sends MIDI input via USB directly to a Raspberry Pi Zero. Then the MIDI inputs are read using the Mido Python library. For every
note_on event, the Zero sets the colour of LEDs using the NeoPixel library.
Each note corresponds to a single colour, and if you play a circle of fifths, the LEDs will display the colours of the rainbow.
The maker used this guide from the fine folk at Adafruit to learn how to control the lights with a Python script on their Raspberry Pi. And they purchased an affordable strip of WS2811 RGB LED lights from Amazon to complete the hardware side of things.
What’s the circle of fifths?
The circle of fifths is a way of arranging the twelve pitches of a chromatic scale as a sequence of perfect fifths. If you choose the note C as your starting point, the sequence is: C, G, D, A, E, B, F♯, C♯, G♯/A♭, E♭, B♭, F. Continuing the pattern from F returns the sequence to its starting point of C.
Let’s have a listen!
This is an unusual portrait-style demonstration video, in order to capture the size of the LED rainbow in action around the big bookcase behind the piano.
While bots can annoy us on Twitter, we made an exception for the clever one that popped up in the comments to correctly detect that the piece played in the video above is Chopin’s Nocturne in B♭ minor. Be honest, who actually knew that before reading this bit?
We vote the maker tweaks their music choice and posts a Christmassy update. We need to see these lights choreographed to the iconic opening bars of Mariah Carey’s All I Want for Christmas.
And we are extra impressed that this was maker RandomBrasilian‘s first go at using a Raspberry Pi. So were lots of users in the comments section; JoThreat2K commented that the project is “One of the most beautiful displays of technology I’ve ever seen”.
Comments are closed