Arduino – A Basic Theremin

basic theremin

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 Arduino 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: Arduino SRF05 Projects. If you can’t be arsed with reading any of that then no worries all is revealed below…

Arduino Theremin Parts List

1x speaker
SRF05 Ultrasonic range finder
Arduino Deumilanove w/ ATMEGA328
Breadboard / Prototyping board
Jumper/ Connector wires

Arduino Theremin 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.


Theremin Arduino 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:
// 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

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);
  digitalWrite(speakerPin, LOW);

[ad#Google Ad in content]

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.


  • Thanks for this Larry – I’m a complete noob to electronics and programming but I picked up an arduino for the laugh. This project could not have been easier but I way more fun than making an LED blink. Always wanted a theremin. Cheers for sharing your knowledge. Peace.

  • this is no theremin, real thereminvox uses two oscillators, with the frequency of one being influenced by electric field changes generated by repositioning of your hand. The frequency difference between those two oscilators is audible and played. Other couple of oscilators may be used to control volume as well.
    What you present here is ‘cannon on pigeon’ approach, your scheme is far beyond 1920’s technology level and an ultimat disgrace to good engineering practice. I am really sorry for limited people who use programmable cicruits to design things this simple..

    • Hi ‘asaf’,

      Firstly thanks for taking the time to comment, even if you can’t provide a real name or email address – perhaps you’re scared of a response when you write unconstructive criticism?

      I’m not sure whether to be proud that I’m beyond 1920’s technology or disappointed in being a disgrace to engineering – although I have never made the claim to be an engineer, if you look at most of the projects you see it’s about programming rather than engineering.

      Please when you write comments like this, at least add reference points for the rest of us lesser mortals to learn from, it’s exactly your kind of approach that disuades the novices like us from looking to far into electronics where you rant but provide no alternative or anything to be gained. It’s exactly that kind of thinking and response that ruins the world.

      Feel free to write back, but please at least be constructive – if not for my benefit but for anyone else who reads the unconstructive narrow minded garbage you have taken the time to write (without a real name or email).

      Oh and I call it a ‘basic Theremin’ because it mimics a real life Thermin programmatically using a sensor instead and produces sounds based up the movement of the user much like the real life Theremin – I don’t believe that there’s a musical instrument or device that comes as close as describing the example I shared. Technology has advanced to a level that we just need a half decent program to replicate all those circuits – but then, you’re clearly stuck up there on your pedestal in the 1920’s declaring narrow minded heresy on those who try something different.

      If you wish to respond, please be constructive for everyone’s benefit.


  • I followed your instructions to the letter, and all I get is a sort of rhythmic clicking from the speaker. Any idea what I might be doing wrong?

    • hmmm…. probably not enough power is getting through or more likely my photos aren’t that clear and something’s in the wrong place. Send us a picture of your circuit if possible.

  • I’d really like to build one of these. I’m also very confused on how to, and how to program it. I have no clue what to apply the above code to. Thanks

  • Hey there,
    I am using a Parallax PING))) sensor, which only has one signal pin. How do I modify the code so that I can use it with my sensor?
    Rory the Noob

  • Nevermind the above comment, I just made the both sensor pin values the same. However, I am getting nothing but “click click click”… from my piezo speaker. Should I have used a real speaker?
    Again From,
    Rory the Noooooob

  • can i use the same with an hc-sr04? i didnt find the srf05, will it work the same with the hc-sr04?

You must be logged in to post a comment.