For this project I used the setup for the Thermin and added an air pocket. I want to use this air pocket as a pillow and simulate air being released through the piezo speakers.
/* Air Pocket Theremin
* --------
*
*
* Created 24 October 2006
* copyleft 2006 Tod E. Kurt <tod@todbot.com
* http://todbot.com/
*/
int potPin = 0; // select the input pin for the potentiometer
int speakerPin = 7;
int val = 0;
void setup() {
pinMode(speakerPin, OUTPUT);
Serial.begin(9600);
Serial.println("ready");
}
void loop() {
digitalWrite(speakerPin, LOW);
val = analogRead(potPin); // read value from the sensor
val = val/2; // process the value a little
//val = val/2; // process the value a little
for( int i=0; i<50; i++ ) { // play it for 50 cycles
digitalWrite(speakerPin, HIGH);
delayMicroseconds(val);
digitalWrite(speakerPin, LOW);
delayMicroseconds(val);
}
}
- Login to post comments