#include <Plaquette.h>
const float PWN_WAVE_FREQUENCY = 100.0f; // 100Hz
const float PWN_WAVE_PERIOD = 1.0F / PWN_WAVE_FREQUENCY;
const int N_LEDS = 8;
AnalogIn pot(A0);
DigitalOut leds[] = { 2, 3, 4, 5, 6, 7, 8, 9 };
SquareWave waves[] = { PWN_WAVE_PERIOD, PWN_WAVE_PERIOD, PWN_WAVE_PERIOD, PWN_WAVE_PERIOD,
PWN_WAVE_PERIOD, PWN_WAVE_PERIOD, PWN_WAVE_PERIOD, PWN_WAVE_PERIOD };
TriangleWave oscillator(1.0, 0);
Metronome metroPotUpdate(0.1);
void begin() {
}
void step() {
if (metroPotUpdate) {
oscillator.period(pot.mapTo(5, 0.2));
for (int i=0; i<N_LEDS; i++) {
float value = oscillator.shiftBy(mapTo01(i, 0, N_LEDS-1));
waves[i].width(value);
}
}
for (int i=0; i<N_LEDS; i++) {
waves[i] >> leds[i];
}
}