Optical Theremin With Arduino Uno

3.5K123

Intro: Optical Theremin With Arduino Uno

A theremin is an electronic instrument in which two high-frequency oscillators control tone while the musicians hand movements control the pitch.

In this Instructable, we'll build a similar instrument, in which hand movements control the amount of light that the instrument's sensors receive, and that light measurement is converted into a resulting pitch from a buzzer.

Parts you'll need:

Arduino microcontroller

Breadboard

10 K Ohm resistor

Jumper wires

1 Piezo Buzzer

Photoresistor

STEP 1: Connect to Power

Start by connecting your breadboard's positive row to the 5V pin on the Arduino Uno.

STEP 2: Connect to Ground

Then connect one of the GND pins to the negative line on your Arduino.

STEP 3: The Buzzer

Insert your buzzer. It likely has a longer leg, or a small "+" sign on the top. Keep track of which side the longer leg or "+" sign are on.

STEP 4: Ground the Buzzer

Connect the shorter leg of the buzzer to ground by inserting a wire in the same row as the shorter leg of the buzzer, and in the negative line on the breadboard.

STEP 5: Power the Buzzer

Complete the buzzer circuit by connecting it to pin 12 on the Arduino.

STEP 6: The Photoresistor

Start building the photoresistor circuit by inserting the photoresister so that it has one leg on each side of the channel down the middle of the breadboard.

STEP 7: Connect the Photoresistor to Power

Use a wire to connect one leg of the photoresistor to the positive line on your breadboard that you connected to 5V earlier.

STEP 8: Ground the Photoresistor

Connect the photoresistor's other leg to ground, connecting the 10K Ohm resistor to the negative line on your breadboard.

STEP 9: Step 9: Connect the Photoresistor to the Arduino

We'll read the change in current through the resistor by connecting a wire between the photoresistor and its ground wire, back to pin A0 on the Arduino.

STEP 10: Step 10: Write Your Code

int analogPin = A0;

int noteToPlay;

int sound; int speaker = 7;

void setup() {

Serial.begin(9600);

pinMode(analogPin, INPUT);

}

void loop() {

sound= analogRead(analogPin);

delay(200);

int notes[21] = {65, 73, 82, 87, 98, 110, 123, 131, 147, 165, 175, 196, 220, 247,262, 294, 330, 349, 392, 440, 494};

noteToPlay= map(sound, 0,1023, 0, 21);

tone(speaker, notes[noteToPlay]); delay(10);

}

STEP 11: Want More Projects Like This?

Check out MakeCrate!

2 Comments

Hi there,

I just made this and found out that there is a mistake in the code which I copy pasted from this Instructable.
It says to connect the speaker to pin 12, but when I did this, nothing happened... I checked the code and saw that it says: int sound; int speaker = 7;
So when I connected the speaker to pin 7, it worked perfectly :)

Besides from that, this is a really fun and easy project with which I intend to play around a bit more.
Thanks for sharing!

This looks like a really fun project! Thanks for sharing!