A Mechanical MIDI Orchestra Made From Relays

This ESP32 MIDI orchestra turns fast-switching relays into a noisy 8-voice mechanical synth, proving even simple hardware can make music.

Nick Bild
2 hours agoMusic
An unusual mechanical MIDI orchestra (📷: Zip_ties_and_psi)

If you try hard enough, just about anything can be coerced into making music. From the clatter of kitchen utensils and the percussive slap of bare hands on a tabletop, to the resonant twang of a rubber band stretched across a tin can, the potential for sound is universal. The main ingredient needed to create a novel musical instrument is creativity.

Consider Redditor Zip_ties_and_psi’s odd mechanical MIDI orchestra, for instance. What began as a simple experiment in abusing electromechanical hardware turned into a surprisingly good relay-based MIDI player. The idea is simple enough: take the clacking of fast-switching relays and shape it into a sequence of musical notes. But executing on that plan took a lot of effort. Oh, and one note — if you care about your relays at all, don’t put them through this kind of abuse.

The instrument is built around an LC ESP32 Relay X8 board, a compact module that pairs an ESP32 microcontroller with eight onboard mechanical relays. While relays are generally intended for slow, infrequent switching, this project pushes them to their limits, driving them at anywhere from 50 to 150 Hz. Each relay becomes a “voice” in an eight-note mechanical synth, with different relays tuned to different buzz frequencies. When several relays are energized simultaneously, the resulting cluster of clicks and buzzes forms a chord.

To make this work, the ESP32 itself doesn’t interpret MIDI directly. Instead, a Python script on a PC handles the heavy lifting. Using the mido library, the script ingests a standard MIDI file, calculates timing based on the file’s tempo, and tracks which musical notes are active at any moment. Those notes are then mapped into eight frequency “bins,” each corresponding to a relay. The script outputs a long list of mask-and-duration pairs, effectively describing which relays should be active and for how long. This data is pasted directly into the main Arduino sketch as a C++ array.

Once flashed, the ESP32 boots into access-point mode under the name “RelayMidi.” A simple web interface provides Play, Stop, and speed-adjustment controls. As the ESP32 cycles through the song data, it rapidly toggles relays according to the masks, turning the fragile components into a rhythmic percussion section that can chug along for as long as they survive.

It’s loud, impractical, and definitely not relay-friendly, but as a reminder of how far creativity can stretch simple hardware, this clattering contraption is hard to beat.

Nick Bild
R&D, creativity, and building the next big thing you never knew you wanted are my specialties.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles