Play Music on This Lego Guitar Using Capacitive Buttons and a Raspberry Pi
Katie Dumont's latest project turns a Lego guitar from a static object into something that can be played like the real thing.
The concept
Element14 Presents host Katie Dumont is no stranger to integrating electronics into Lego sets, as her previous Lego Raspberry Pi HQ Camera and Raspberry Pi Lego Train projects have demonstrated. This time around, her son, John, requested that she take a Lego guitar and make it play real music without many modifications, which would require some creative use of inputs so no electronics could be easily seen.
Capacitive touch sensing
The majority of toy guitars rely on integrated pushbuttons to signal that a note should be played when it is pressed, but due to the fact that this guitar is meant to be taken apart, the solution is far from ideal. Instead, capacitive touch sensors can be used just like a normal pushbutton, except they use the body's natural electric field to detect changes in a conductor's capacitance and report it back via a sensor. For her project, Dumont selected the Seeed Studio MPR121 Touch Sensor Board which communicates over I2C and can sense across multiple channels.
Programming
Based on a Raspberry Pi 3A, the Python program that Dumont wrote starts with initializing the MPR121 sensor by writing a few configuration values and clearing any existing data. Next, it enters into an infinite loop that continuously checks the MPR121 for which, if any, channels have been touched, and if they have, play the associated sound via the Pygame library.
Playing the guitar
Once the copper tape was in place and covered with a thin color-matched vinyl wrap, John got to jam out with his new Lego guitar. Making things even more convincing is how Dumont placed the Pi, its speaker, and amp into a mini Lego electric guitar amp, thus completing the set. To see more about how this project was made, you can watch the video here on the Element14 Presents YouTube channel.