Created
February 18, 2019 02:48
-
-
Save blister/2902cede55b4a3064e0c241a763cde72 to your computer and use it in GitHub Desktop.
Theremin Ranging
This file contains 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
void loop() { | |
// put your main code here, to run repeatedly: | |
long dist = msToCm(ping()); | |
if ( dist < 100.00 ) { | |
toneCounter = 0; | |
// 1 == min distance in cm | |
// 100 == max distance in cm | |
// 1500 == max frequency | |
// 500 == min frequency | |
int pitch = map(dist, 1, 100, 1568, 784); | |
tone(buzzer, pitch); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment