Skip to content

Instantly share code, notes, and snippets.

@spilth
Created October 19, 2014 21:33
Show Gist options
  • Save spilth/9d3aef8569822268a10c to your computer and use it in GitHub Desktop.
Save spilth/9d3aef8569822268a10c to your computer and use it in GitHub Desktop.
littleBits Arduino Slider Scale Jam
const int sliderInput = A0;
const int oscillator = 5;
void setup() {
pinMode(oscillator, OUTPUT);
Serial.begin(9600);
}
int scale[] = {12, 20, 32, 40, 48, 60, 68, 80, 88, 96, 108};
void loop() {
int sensorReading = analogRead(sliderInput);
int scaleIndex = map(sensorReading, 7, 1016, 0, 10);
int pitch = scale[scaleIndex];
analogWrite(oscillator, pitch);
delay(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment