Theremins are cool. Fact. You may also have heard of them as either aetherphone/ etherophone or termenvox/ thereminvox. Essentially its an electronic music instrument that plays a certain note depending on the position of your hand and its distance from an antenna.
Building a very basic one with Arduino is easy – easier than my basic drum machine. Very easy. Basically we can replicate one by building a circuit of a speaker and a distance sensor, such as my favourite the SRF05 ultrasound thingy. We calculate the distance and the nearer you get the difference in note/frequency emitted from the speaker.
You’re going to need only a few parts and not much code. You can read more about my applications of the SRF05 along with sample code here. If you can’t be arsed with reading any of that then no worries all is revealed below…
Shopping list
1x speaker
SRF05 Ultrasonic range finder
Arduino Deumilanove w/ ATMEGA328
Breadboard / Prototyping board
Jumper/ Connector wires
Optional 9V power supply (here) or use the USB power for the Arduino
The Circuit
Very simple,we have a speaker with the negative running to Arduino’s GND, and it’s positive going to digital pin 6 on the Arduino board. The code will tell the speaker to turn on and off rapidly based on the objects distance from the ultrasound sensor. This rapid turning on and off of the speaker is what will generate different sounds (like my drum machine). The only other part of the circuit is the SRF05 distance/ proximity sensor. It has a positive and negative connected to the Arduino and then 2 pins for trigger and echoing an ultrasound wave both going to digital pins 2 and 3 respectively on the Arduino board.
The Sketch
To save the annoyance of those around you I’ve added in a small statement that basically says if your hand is not within 30 cm of the sensor then don’t play a sound. But otherwise basically we measure distance constantly and when an object is detected we convert the distance in to a value for which to use in the oscillation of the speaker to generate different pitchs and frequencies.
// written at: luckylarry.co.uk // very easy Theremin // setup pins and variables for SRF05 sonar device int echoPin = 2; // SRF05 echo pin (digital 2) int initPin = 3; // SRF05 trigger pin (digital 3) int speakerPin = 6; // Speaker pin unsigned long pulseTime = 0; // stores the pulse in Micro Seconds unsigned long distance = 0; // variable for storing the distance (cm) we'll use distance as a switch for the speaker unsigned long soundDelay = 0; // variable for storing the deay needed for the pitch //setup void setup() { pinMode(speakerPin, OUTPUT); // sets pin 6 as output pinMode(initPin, OUTPUT); // set init pin 3 as output pinMode(echoPin, INPUT); // set echo pin 2 as input } // execute void loop() { digitalWrite(initPin, HIGH); // send 10 microsecond pulse delayMicroseconds(10); // wait 10 microseconds before turning off digitalWrite(initPin, LOW); // stop sending the pulse pulseTime = pulseIn(echoPin, HIGH); // Look for a return pulse, it should be high as the pulse goes low-high-low distance = pulseTime/58; // convert the pulse into distance (cm) soundDelay = pulseTime/3; // alter this variable to alter the pitch of the sound emitted // make the sound. // check the distance, if over 30cm make no sound if (distance < 30) { digitalWrite(speakerPin, HIGH); delayMicroseconds(soundDelay); digitalWrite(speakerPin, LOW); delayMicroseconds(soundDelay); } }
The Result
Pretty cool for no parts – but of course the sound quality isn’t great. I guess you could add a switch in the circuit so you could manually start and stop it to produce clearer notes.
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.
- Arduino: Basic Theremin meets Processing!
- Arduino: making a basic drum machine
- Arduino + Processing: Make a Radar Screen to Visualise Sensor Data from SRF-05 – Part 2: Visualising the Data
- Arduino + Processing: Make a Radar Screen to Visualise Sensor Data from SRF-05 – Part 1: Setting up the Circuit and Outputting Values
- Obstacle avoidance robot – build your own larryBot
- larryBot – versions 0.1 to 0.5 lessons learned
- Arduino + Processing: Getting values from SRF05 ultrasound sensor & serial port
- Arduino: Sonic range finder with SRF05
- Arduino: IR remote/ intervalometer for Nikon D80 DSLR (that means timelapse photography yarrr!)
- 3 LED Crossfade with PWM and Arduino










