Making Things Interactive

February 12, 2008

Arduino Theremin

Filed under: 5: Making Motion — Dae @ 1:24 pm

I am trying to make a theremin with my Arduio. I used a ultrasonic distance sensor to detect the distance from the sensor to hand gesture. To make a complete theremin, I need two sensors; one for pitch and the other for volume. I couln’t figure out how to control the volume of the pulse with the other sensor, yet.

/* Make basic version of Theremin with Arduino and Ultrasound Sensor
* for Making Things Interactive Class
* by Dae Hong Kim
*/

int ultraSoundSignal = 7;
int toSpeaker = 10;
int val;

void setup()
{
beginSerial(9600);  //Sets the baud rate to 9600
pinMode(toSpeaker, OUTPUT);  //set speaker pin to output
}

int getPing()  //send a 10us pulse to wake up the sonar
{
pinMode(ultraSoundSignal, OUTPUT);
digitalWrite(ultraSoundSignal, HIGH);
delayMicroseconds(10);
digitalWrite(ultraSoundSignal, LOW);

pinMode(ultraSoundSignal, INPUT);
return pulseIn(ultraSoundSignal, HIGH);  //return this value
}

void loop()
{
val = getPing();
digitalWrite(toSpeaker, HIGH);
delayMicroseconds(val);
digitalWrite(toSpeaker, LOW);
delayMicroseconds(val);
}

Advertisements

1 Comment »

  1. Would like to see the schematic, pictures, video. Code alone is not enough.

    Comment by mdgross — February 13, 2008 @ 7:18 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: