Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ultrasonic Theremin for Sparki
#include <Sparki.h>
void setup() {
}
void ultrasonicTheremin(){
int maxDist = 60;
int minFreq = 50;
int maxFreq = 10000;
int freq = 0;
sparki.RGB(RGB_BLUE);
int ping = sparki.ping();
if ( ping > 1 && ping <= maxDist){
freq = map(ping, 0, maxDist, minFreq, maxFreq);
sparki.beep(freq);
} else {
sparki.noBeep();
}
}
void loop(){
ultrasonicTheremin();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment