Skip to content

Instantly share code, notes, and snippets.

@mithi
Created October 6, 2015 06:53
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 mithi/c9d667da72b4c3b913fe to your computer and use it in GitHub Desktop.
Save mithi/c9d667da72b4c3b913fe to your computer and use it in GitHub Desktop.
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