Arduino Theremin

Background Knowledge:


What you'll need:

1 - 9 Volt Battery

1 - 9 Volt Battery Harness

1 - Breadboard

1 - Arduino UNO

2 - LDR Light

1 - 3904 NPN Transistor

1 - Piezo Buzzer

1 - LED

1 - 10K Ohm Potentiometer

2 - 10K Ohm Resistor

1 - 470 Ohm Resistor

A theremin is an electronic musical instrument known for its unique and ethereal sound. Invented by Russian physicist and musician Leon Theremin in 1920, the theremin stands out as one of the earliest electronic instruments. It's recognized for its distinctive feature of being played without physical contact, as the musician controls pitch and volume by moving their hands through the air near the instrument.

Playing the theremin requires a delicate and precise technique. The musician's hands act as virtual antennae and the interaction with the electromagnetic fields determines the pitch and volume of the sound produced. Movements must be controlled and precise to achieve the desired musical expression.

This project is a version of a theremin that uses a piezo buzzer to make sound and changes volume and pitch based on the amount of light detected by LDRs instead of the distance of your hands from distance sensors (the theremin works essentially the same way with LDRs).


 2. Write the Arduino Sketch

This code expands on the open-source 'LightTheremin' project code provided by Arduino. There is an initial 5-second calibration period to allow the theremin to adjust to the ambient light in the room.

// variable to hold sensor value

int pitchValue;

// variable to calibrate low value

int pitchLow;

// variable to calibrate high value

int pitchHigh;


void setup() {

  

  // Make the LED pin an output and turn it on

  pinMode(13, OUTPUT);

  digitalWrite(13, HIGH);


  // calibrate for the first five seconds after program runs

  pitchHigh = analogRead(A0);

  pitchLow = analogRead(A0);

  while (millis() < 5000) {

    // record the maximum sensor value

    pitchValue = analogRead(A0);

    if (pitchValue > pitchHigh) {

      pitchHigh = pitchValue;

    }

    // record the minimum sensor value

    if (pitchValue < pitchLow) {

      pitchLow = pitchValue;

    }

  }

  // turn the LED off, signaling the end of the calibration period

  digitalWrite(13, LOW);

}


void loop() {

  //read the input from A0 and store it in a variable

  pitchValue = analogRead(A0);


  // map the sensor values to a wide range of pitches

  int pitch = map(pitchValue, pitchLow, pitchHigh, 50, 4000);


  // play the tone for 20 ms on pin 8

  tone(8, pitch, 20);


  // wait for a moment

  delay(10);

}

3. Upload and Adjust the Circuit

4. Understand the Code

pitchHigh = analogRead(A0);

pitch low = analogRead(A0);

 // record the maximum sensor value

pitchValue = analogRead(A0);

if (pitchValue > pitchHigh) {

 pitchHigh = pitchValue;

 }

// record the minimum sensor value

if (pitchValue < pitchLow) {

pitchLow = pitchValue;

}

}

5. Calibrate and Play

Questions:

Special Note: 

Maker Lessons is proud to help teach both in front and behind the scenes. Maker Lessons provides internship opportunities where STEM students have the opportunity to make pages like this one. This page was made by I.G.