Created
April 26, 2015 22:09
-
-
Save proudlygeek/5b87e35ba4331143c4c0 to your computer and use it in GitHub Desktop.
Theremin
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
| int sensorValue; | |
| int sensorLow = 1023; | |
| int sensorHigh = 0; | |
| const int ledPin = 13; | |
| void setup() { | |
| pinMode(ledPin, OUTPUT); | |
| digitalWrite(ledPin, HIGH); | |
| while(millis() < 5000) { | |
| sensorValue = analogRead(A0); | |
| if (sensorValue > sensorHigh) { | |
| sensorHigh = sensorValue; | |
| } | |
| if (sensorValue < sensorLow) { | |
| sensorLow = sensorValue; | |
| } | |
| } | |
| digitalWrite(ledPin, LOW); | |
| } | |
| void loop() { | |
| sensorValue = analogRead(A0); | |
| int pitch = map(sensorValue, sensorLow, sensorHigh, 50, 4000); | |
| tone(8,pitch,20); | |
| delay(10); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment