# Theremin

3,147

31

3

Actually, I wasn't planing on making a theremin, I was exploring the arduino sound capability and kinda drift into it...
This is an easy Saturday project.

Whatch

You will need :
Arduino - I used the pro mini
220 ohm resistor
A speaker
an Infrared proximity sensor

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Explanation

The arduino sens the proximity of the hand and divide it to 15 notes according to the 4th and 5th octave ending with the 6th C to realize what note to play
Then according to where the output Hertz are at the moment it will decrease or increase to match that note.

## Step 2: The Code

`int oct [15] = {262, 294, 330, 349, 392, 440, 494, 523, 587, 659, 698, 784, 880, 988, 1047};`
`int Play = oct [0];`
```void setup (){
pinMode (5, OUTPUT);
pinMode (A1, INPUT);
Serial.begin (9600);
}```
```void loop (){
int Hz = constrain (map (analogRead (A1), 100, 500,0, 14), 1, 14);
Serial.println (Play);
if (Play > oct [Hz]) {Play = Play - 6;}
if (Play < oct [Hz]) {Play = Play+6;}
tone (5,Play );
// delay (100);
}```

1 922
1 144
93 5.9K

## 3 Discussions

Hye.

The code will not work as is with hc-sr04. the hc-sr04 communicate differently with the arduino.
The transistor is not included in the partlist by mistake, it is a regular NPN 2222 transistor.
The code might work as is in another sketch if you keep the pins setting on the arduino and also depend on your surcuits.

Hi udubinsky, very nice ible. Your theremin is achieved using the smallest number of parts that I've seen, which is cool. Would this code work if I used an hc-sr04 as proximity sensor? & as I'm not very code savvy can I just cut & paste the pieces of your code into an arduino sketch to make it work? I see a transistor that's not included in your parts list. Any particular one?

You obviously know your stuff cuz I have no idea what your saying with your dividing notes & octaves!

If you lowered the tone a bit, this would make a brilliant booby-trap, squawking as folk walked past or reached over it.