#include <Adafruit_NeoPixel.h>
#include <Plaquette.h>
#define NEOPIXEL_PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit...if you must, connect GND first.
SquareWave wave(5.0, 0.25);
TriangleWave lfo(15.0, 0);
SineWave sine(3.0);
DigitalIn button(2, INTERNAL_PULLUP);
boolean reverse = false;
void begin()
{
button.debounce();
strip.begin();
strip.show(); // Initialize all pixels to 'off'
button.onRise([]() { reverse = !reverse; });
}
void step() {
sine.period( lfo.mapTo(0.5, 3) );
if (reverse)
sine.reverse();
// for(uint16_t i=0; i<strip.numPixels(); i++) {
// strip.setPixelColor(i, strip.Color( sine.mapTo(0, 255), 0, 0 ));
// }
for(uint16_t i=0; i<strip.numPixels(); i++) {
float value = sine.shiftBy( mapFloat(i, 0, strip.numPixels()-1, 0, 3) );
strip.setPixelColor(i, strip.Color(value*255, 0, 0) );
}
strip.show();
}