The idea
Element14 Presents host Katie Dumont is not any stranger to integrating electronics into Lego units, as her earlier Lego Raspberry Pi HQ Digital camera and Raspberry Pi Lego Prepare tasks 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
The vast majority of toy guitars depend on built-in pushbuttons to sign {that a} notice ought to be performed when it’s pressed, however on account of the truth that this guitar is supposed to be taken aside, the answer is way from superb. As an alternative, capacitive contact sensors can be utilized identical to a standard pushbutton, besides they use the physique’s pure electrical area to detect modifications in a conductor’s capacitance and report it again through a sensor. For her challenge, Dumont chosen the Seeed Studio MPR121 Contact Sensor Board which communicates over I2C and may sense throughout a number of channels.
Programming
Primarily based on a Raspberry Pi 3A, the Python program that Dumont wrote begins with initializing the MPR121 sensor by writing a couple of configuration values and clearing any present knowledge. 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 through 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 bought to jam out along 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 challenge was made, you may watch the video right here on the Element14 Presents YouTube channel.