/
auto_mode_cycle.ino
39 lines (31 loc) · 1.11 KB
/
auto_mode_cycle.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <WS2812FX.h>
#define LED_COUNT 13
#define LED_PIN 11
#define TIMER_MS 5000
// 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)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800);
unsigned long last_change = 0;
unsigned long now = 0;
void setup() {
ws2812fx.init();
ws2812fx.setBrightness(255);
ws2812fx.setSpeed(1000);
ws2812fx.setColor(0x007BFF);
ws2812fx.setMode(FX_MODE_STATIC);
ws2812fx.start();
}
void loop() {
now = millis();
ws2812fx.service();
if(now - last_change > TIMER_MS) {
ws2812fx.setMode((ws2812fx.getMode() + 1) % ws2812fx.getModeCount());
last_change = now;
}
}