Created
October 16, 2013 01:07
-
-
Save seekshreyas/7001114 to your computer and use it in GitHub Desktop.
Smoker Shame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 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