Skip to content

Instantly share code, notes, and snippets.

@seekshreyas
Created October 16, 2013 01:07
Show Gist options
  • Select an option

  • Save seekshreyas/7001114 to your computer and use it in GitHub Desktop.

Select an option

Save seekshreyas/7001114 to your computer and use it in GitHub Desktop.
Smoker Shame
/* Theremin
* --------
*
*
* Created 24 October 2006
* copyleft 2006 Tod E. Kurt <[email protected]
* 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
// Serial.println(val);
if (val > 400){
for( int i=0; i<10; i++ ) { // play it for 10 cycles
digitalWrite(speakerPin, LOW);
delayMicroseconds(val);
digitalWrite(speakerPin, HIGH);
delayMicroseconds(val);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment