Control a Glockenspiel with Sonic Pi and Lego!

Perhaps the glockenspiel isn’t the first instrument you think of when it comes to electronic music, but thanks to the wonderful Sonic Pi software, that might be about to change...

Built by YouTuber Robin Newman (rbn1tube), the project uses Lego hammers, which are controlled by 11 Adafruit 5V solenoids, and these are connected to a Raspberry Pi 3’s GPIO.

It’s worth noting that the Lego hammers hit the glockenspiel from below, rather than above. “I wanted to use gravity to return the hammers to their resting position, so this entailed hitting the notes from the underneath rather than from on top in normal player mode,” writes Newman, “also, the spacing of the keys has to be appropriate for use with the lego construction, the pitch of my hammers being three lego holes or about 24mm.” Meantime, while each hammer can sit individually on a table (possibly held by some adhesive putty), it’s worth following Newman’s lead and using a baseplate to reduce movement.

The hammers are connected to the Raspberry Pi 3 via a RasPiO ProHat, and two circuits: one for the solenoids, and another for the necessary transistors.

To create music with this project, a Python script that drives the solenoids (using the GPIOZERO Python library) is employed, but the music itself comes from Sonic Pi, the popular music-making application which is not only available for other platforms, it now comes pre-installed with the latest version of Raspbian!

In the video above, you’ll see a performance of the Raspberry Pi and Lego-powered glockenspiel, alongside some Sonic Pi-programmed instruments. You’ll agree that the results are impressive, as Sonic Pi not only plays the glockenspiel, it also plays other musical voices to accompany.

Check the full blog post for a detailed look at the build, paying particular attention to how the Lego hammers are built.


Christian Cawley

Christian Cawley spends a lot of time with Raspberry Pis and scours the web looking for interesting DIY electronics projects and news for ElectroMaker. He's currently trying to show his 7 year old son how to get to grips with Scratch, but so far to no avail.


Leave your feedback...

Latest Articles