Attached potentiometer to speaker, adding an LED, and a pressure sensitive LED as a rudimentary game of simon.
Joe
Here is the code:
/* Theremin* --------*** Created 24 October 2006* copyleft 2006 Tod E. Kurt <tod@todbot.com* http://todbot.com/*/int potPin = 2; // select the input pin for the potentiometerint speakerPin = 7;int sensorPin = 0; // select the input pin for the sensorint ledPin = 10;int val = 0;int wal = 0;void setup() {pinMode(11, OUTPUT);pinMode(10, OUTPUT);pinMode(9, OUTPUT);pinMode(speakerPin, OUTPUT);Serial.begin(9600);Serial.println("ready");}void loop() {digitalWrite(speakerPin, LOW);val = analogRead(potPin); // read value from the sensorwal = analogRead(sensorPin); // read the value from the sensor, 0-1023for( int i=0; i<100; i++ ) { // play it for 50 cyclesdigitalWrite(speakerPin, HIGH);delayMicroseconds(val);digitalWrite(speakerPin, LOW);delayMicroseconds(val);}analogWrite(ledPin, wal/5); // analogWrite (dimming the LED) can be between 0-255Serial.println(wal/5); // writing the value to the PC via serial connectiondigitalWrite(11, HIGH); // set the LED ondelay(val); // wait for a seconddigitalWrite(11, LOW); // set the LED offdelay(val); // wait for a secondif (val = wal){digitalWrite(9, LOW);// turn off led}else{digitalWrite(9, HIGH); // turn on led}}