Created
October 14, 2010 20:14
-
-
Save Kobold/626954 to your computer and use it in GitHub Desktop.
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 potpin = 0; | |
| int speakerPin = 9; | |
| int redPin = 10; | |
| int bluePin = 12; | |
| int high = 0, low = 500; | |
| void setup() | |
| { | |
| pinMode(speakerPin, OUTPUT); | |
| } | |
| void loop() | |
| { | |
| int val = analogRead(potpin); | |
| high = max(high, val); | |
| low = min(low, val); | |
| analogWrite(redPin, map(val, low, high, 0, 255)); | |
| analogWrite(bluePin, map(val, low, high, 255, 0)); | |
| int tone = map(val, low, high, 1915, 956); | |
| digitalWrite(speakerPin, HIGH); | |
| delayMicroseconds(tone); | |
| digitalWrite(speakerPin, LOW); | |
| delayMicroseconds(tone); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment