Skip to content

Instantly share code, notes, and snippets.

@blister
Created February 18, 2019 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blister/2902cede55b4a3064e0c241a763cde72 to your computer and use it in GitHub Desktop.
Save blister/2902cede55b4a3064e0c241a763cde72 to your computer and use it in GitHub Desktop.
Theremin Ranging
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