Teensy Les Smoothing
elapsedMillis forLoopLength;
void setup() {
// put your setup code here, to run once:
pinMode(15, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//maak een variabele om het totaal van alle lezingen bij te houden
int potSum = 0;
forLoopLength = 0;
for (int i = 0; i < 500; i ++) {
//doe iets 100 keer en tel in i hoe vaak we het al gedaan hebben
potSum = potSum + analogRead(15); //0 - 1023
}
//reken het gemiddelde uit van alle 100 lezingen
potValue = potSum / 500;
int potMIDI = map(potValue, 0, 1023, 0, 127);
Serial.println("Forlooplength = " + String(forLoopLength));
Serial.println("Potraw:" + String(analogRead(15)) + ",potValue:" + String(potValue));
usbMIDI.sendControlChange(1, potMIDI, 1);
delay(10);
}