Description:
Falling short of a tuned instrument, this "flute" works like a real flute in some respects. As fingers are removed from the body of the "flute," the tone gets lower. A photosensor drops the tone as more light is allowed in the tube. The pressure sensor allows for the program to run when the lips press down on it. A piezo speaker sings the tune.
Materials Used:
Arduino
Breadboard
(2) 10-Ω resistors
Piezo speaker
Photosensor
FSR
Paper towel tube
Arduino Code:
/Theremin code adapted from Tod E. Kurt's example. Todbot.com
*Ryan Kaufman
*/
int photoPin = 0; // select the input pin for the photosensor
int fsrPin = 1; // select the input pin for the FSR
int speakerPin = 7;
int photoval = 0;
int fsrval = 0;
void setup() {
pinMode(speakerPin, OUTPUT);
beginSerial(9600);
Serial.println("ready");
}
void loop() {
if (fsrval < 150); // set threshold value on FSR for program to proceed.
Serial.print (fsrval); // read input.
digitalWrite(speakerPin, LOW);
photoval = analogRead(photoPin); // read value from the sensor
photoval = photoval*2; // process the value a little
//photoval = photoval/2; // process the value a little
for( int i=0; i<500; i++ ) { // play it for 50 cycles
digitalWrite(speakerPin, HIGH);
delayMicroseconds(photoval);
digitalWrite(speakerPin, LOW);
delayMicroseconds(photoval);
}
}