How to Build a Theremin You Can Play With Your Whole Body

The TeraRanger One range finder lets you make a musical instrument with infrared light

Advertisement

A few months ago I modified a vintage Casio synthesizer so that it could produce bizarre new sounds. At the same time, I built an interface that allowed an Arduino Mega microcontroller to control the keyboard. This was part of my scheme to use electronic assistance to solve my ongoing problem of not actually being able to play any instrument.

Initially I programmed the Mega simply to play a stored melody. I could have bought and retrofitted a MIDI (Musical Instrument Digital Interface) for such a task, but I used a Mega because I wanted greater flexibility. In particular, I wanted to be able to hook up different sensors and translate their readings into musical notes. So when the makers of the TeraRanger One—a US $140 range-finder sensor—sent me a sample unit, the wheels in my head started turning.

I’d met some of the TeraRanger people last March at the CeBIT technology show. The sensor is actually a spin-off from the CERN nuclear research center, where an inexpensive, lightweight, and precise way to determine distances over a range of several meters was wanted for underground drone surveys. The TeraRanger One measures the time of flight of reflected infrared pulses; it can determine distances with 5-millimeter resolution up to 14 meters away indoors, with a refresh rate of 1 kilohertz.

I realized that with this range and resolution I could build one musical instrument with two different modes of playing it. In the first mode—which I’ve dubbed Air Theremin—the instrument is played with a single hand. By placing my palm somewhere in a range of about a meter above the sensor, I can produce notes using the Casio keyboard. It’s a little like playing a theremin, but without the need for that device’s antenna. In the second mode—dubbed Air Big, after the 1988 film in which Tom Hanks plays a giant piano keyboard embedded into the floor of a toy store—I can play the instrument by putting my entire body in front of the sensor somewhere over the length of a room.

Interfacing the TeraRanger One’s output to the Mega was straightforward. You can configure the sensor to encode a measurement range (in millimeters) as 2 bytes. I connected the TeraRanger One’s transmit and receive lines to two digital pins on the Mega and handled communications using the SoftwareSerial Library.

My biggest problem was avoiding killing the Mega. I recently bought a number of Megas from Micro Center, a U.S. retail store that sells its own line of Arduino clones under its Inland brand. Their Megas typically sell for $20 and can be found on sale for as little as $10, significantly cheaper than other brands. I’ve used these boards before and had no complaints, but as I tested my project, the Mega stopped responding. I replaced it, but then that board went belly-up, too. I chalked up the first failure to bad luck, but after the second identical failure, I started poking around for a cause. Eventually, my attention turned to the generic wall wart I was using as an external power supply.

Often, the 5 volts supplied via the USB connector is enough to run Arduino-based projects, but the TeraRanger One requires 10 to 20 V, with 12 V as the preferred voltage. For the Mega, when it’s running on external power, the recommended range of input voltages is 7 to 12 V, with 6 to 20 V tolerated. So I dug through my pile of accumulated old wall warts until I found one that listed its output as 12 V and passed this external supply through to the TeraRanger One via the Mega’s Vin pin. But when I checked the Vin voltage with a third Mega, I found it was a little over 14 V under the load presented by the Mega and the TeraRanger. My setup just wasn’t drawing enough of a load to pull the wall wart’s voltage down to its rated value.

So I extracted a 9 V wall wart from the pile, which actually provided a little under 10 V under my setup’s load. This was acceptable to the TeraRanger One, and the Mega has been running fine too. Am I sure that the higher voltage (even though still within spec) caused my board failures? No, but because the IEEE isn’t going to let me expense a bunch of Megas just so I can fry them in a set of tests, I’m going to take that answer and run, at least for now.

Mapping the range sensor results onto the Casio’s keyboard was also straightforward: Placing my hand in the air above the sensor reliably produced a note corresponding to the distance from the sensor. But the results were a little boring to listen to. Even if I could play the piano, in the absence of visual reference points, bringing my palm out of the TeraRanger’s field of view and back in at the correct distance for a different desired note would be challenging. And this would be even more difficult in Air Big mode.

The solution was to realize that I wasn’t limited to the Casio’s conventional scale arrangement of octaves and semitones. Inspired by the Animoog iPad app, which allows support for many different on-screen keyboards and scale arrangements, I mapped the TeraRanger results onto a scale of C, D#, E, F, F#, G#, A, B. The result was much more melodious, even when I moved my hand from note to note while staying within the sensor’s field of view.

A single-note melody still sometimes sounded a little thin, so I programmed a lookup table of major chords for each note, and added a switch that would prompt the Mega to automatically play these chords. I also added a potentiometer to adjust the range over which the Mega maps distances to notes. I then mounted the TeraRanger on a wooden box with a hinged lid, which lets me flip the sensor from pointing up to pointing out, to go from Air Theremin to Air Big mode. Testing out the latter has produced some entertaining gyrations from my colleagues here at IEEE Spectrum, although it’s perhaps somewhat less musical than the Air Theremin mode.

This article appears in the October 2016 print issue as “The ‘Air’ Theremin.”

Advertisement