loading

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
Breadboard
220 ohm resistor
A speaker
an Infrared proximity sensor

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);
}
<p>Hye.</p><p>The code will not work as is with hc-sr04. the hc-sr04 communicate differently with the arduino.<br>The transistor is not included in the partlist by mistake, it is a regular NPN 2222 transistor.<br>The code might work as is in another sketch if you keep the pins setting on the arduino and also depend on your surcuits.</p>
<p>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? &amp; as I'm not very code savvy can I just cut &amp; 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?</p><p>You obviously know your stuff cuz I have no idea what your saying with your dividing notes &amp; octaves! </p>
<p>If you lowered the tone a bit, this would make a brilliant booby-trap, squawking as folk walked past or reached over it.</p>

About This Instructable

2,547views

30favorites

License:

More by udubinsky:ENC28J60 Using Ethernet With Arduino Electro Double Pie Face Showdown  Never Forget It on - Energy Saver 
Add instructable to: