Create a gist now

Instantly share code, notes, and snippets.

single light sensor theremin for sparki
#include <Sparki.h>
int sensorLow = 335;
int sensorHigh = 872;
int sensorValue;
int freq = 440;
int maxPitchCount = 20;
void setup(){}
void play(int sensorVal, int sensorLow, int sensorHigh, int freq){
pitchMultiplier = map(sensorVal, sensorLow, sensorHigh, 1, maxPitchCount);
sparki.beep(pitchMultiplier*freq);
delay(20);
}
void loop(){
sparki.RGB(RGB_LED);
sensorValue = sparki.lightLeft();
play(sensorValue, sensorLow, sensorHigh, freq);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment