#include <WS2812FX.h>
#define LED_COUNT 16
#define LED_PIN 1
#define Light_Yellow (uint32_t)0xfad264
#define NUM_SEGMENTS 2
#define NUM_ACTIVE_SEGMENTS 1
#define LOWER_SEG_RANGE 0, LED_COUNT
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800, NUM_SEGMENTS, NUM_ACTIVE_SEGMENTS);
void setup() {
ws2812fx.init();
ws2812fx.setBrightness(200);
// create two active segments
ws2812fx.setSegment(0, LOWER_SEG_RANGE, FX_MODE_RUNNING_LIGHTS, Light_Yellow, 2000, NO_OPTIONS);
// create additional "idle" segments that will be activated later
ws2812fx.setIdleSegment(1, LOWER_SEG_RANGE, FX_MODE_BREATH, YELLOW, 2000, NO_OPTIONS);
ws2812fx.start();
}
void loop() {
static unsigned long timer = millis();
static unsigned int blink_counter = 0;
ws2812fx.service();
/* the lower segment is updated based on a timer.
the lower segment will change every 10 seconds
*/
if(millis() > timer + 10000) { // every 10 seconds...
if(ws2812fx.isActiveSegment(0)) { // if seg[0] is active, switch to seg[2]
ws2812fx.swapActiveSegment(0, 1);
} else { // else, switch to seg[0]
ws2812fx.swapActiveSegment(1, 0);
}
timer = millis();
}
}