The idea
Element14 Presents host Katie Dumont isn’t any stranger to integrating electronics into Lego units, as her earlier Lego Raspberry Pi HQ Digicam and Raspberry Pi Lego Practice initiatives have demonstrated. This time round, her son, John, requested that she take a Lego guitar and make it play actual music with out many modifications, which might require some inventive use of inputs so no electronics may very well be simply seen.
Capacitive contact sensing
Nearly all of toy guitars depend on built-in pushbuttons to sign {that a} notice must be performed when it’s pressed, however resulting from the truth that this guitar is supposed to be taken aside, the answer is way from best. As a substitute, capacitive contact sensors can be utilized identical to a standard pushbutton, besides they use the physique’s pure electrical discipline to detect adjustments in a conductor’s capacitance and report it again by way of a sensor. For her mission, Dumont chosen the Seeed Studio MPR121 Contact Sensor Board which communicates over I2C and may sense throughout a number of channels.
Programming
Based mostly on a Raspberry Pi 3A, the Python program that Dumont wrote begins with initializing the MPR121 sensor by writing just a few configuration values and clearing any current information. Subsequent, it enters into an infinite loop that repeatedly checks the MPR121 for which, if any, channels have been touched, and if they’ve, play the related sound by way of the Pygame library.
Enjoying the guitar
As soon as the copper tape was in place and coated with a skinny color-matched vinyl wrap, John received to jam out together with his new Lego guitar. Making issues much more convincing is how Dumont positioned the Pi, its speaker, and amp right into a mini Lego electrical guitar amp, thus finishing the set. To see extra about how this mission was made, you may watch the video right here on the Element14 Presents YouTube channel.