FastLED 3.10.8
Loading...
Searching...
No Matches
RGBWEmulated.ino
Go to the documentation of this file.
1// @filter: (board is not atmega8*) // RGBW does not fit 8 KB flash (#4805)
2
3#include <FastLED.h>
4
5
6
7// How many leds in your strip?
8#define NUM_LEDS 10
9
10// For led chips like WS2812, which have a data line, ground, and power, you just
11// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
12// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
13// Clock pin only needed for SPI based chipsets when not using hardware SPI
14#define DATA_PIN 3
15
16// Define the array of leds
18
19// Time scaling factors for each component
20#define TIME_FACTOR_HUE 60
21#define TIME_FACTOR_SAT 100
22#define TIME_FACTOR_VAL 100
23
26 kRGBWExactColors, // Mode
27 W3 // W-placement
28);
29
30typedef WS2812<DATA_PIN, RGB> ControllerT; // RGB mode must be RGB, no re-ordering allowed.
32
33void setup() {
34 Serial.begin(115200);
35 //FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS).setRgbw(RgbwDefault());
36 FastLED.addLeds(&rgbwEmu, leds, NUM_LEDS);
37 FastLED.setBrightness(128); // Set global brightness to 50%
38 delay(2000); // If something ever goes wrong this delay will allow upload.
39}
40
41void fillAndShow(CRGB color) {
42 for (int i = 0; i < NUM_LEDS; ++i) {
43 leds[i] = color;
44 }
45 FastLED.show();
46}
47
48// Cycle r,g,b,w. Red will blink once, green twice, ... white 4 times.
49void loop() {
50 static size_t frame_count = 0;
51 int frame_cycle = frame_count % 4;
52 frame_count++;
53
54 CRGB pixel;
55 switch (frame_cycle) {
56 case 0:
57 pixel = CRGB::Red;
58 break;
59 case 1:
60 pixel = CRGB::Green;
61 break;
62 case 2:
63 pixel = CRGB::Blue;
64 break;
65 case 3:
66 pixel = CRGB::White;
67 break;
68 }
69
70 for (int i = -1; i < frame_cycle; ++i) {
71 fillAndShow(pixel);
72 delay(200);
74 delay(200);
75 }
76 delay(1000);
77}
CRGB leds[1]
#define NUM_LEDS
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
void setup()
static RGBWEmulatedController< ControllerT, GRB > rgbwEmu(rgbw)
WS2812< DATA_PIN, RGB > ControllerT
void fillAndShow(CRGB color)
Rgbw rgbw
void loop()
Emulation layer to support RGBW LEDs on RGB controllers.
Definition chipsets.h:196
constexpr EOrderW W3
Definition eorder.h:24
fl::CRGB CRGB
Definition crgb.h:25
constexpr RGBW_MODE kRGBWExactColors
Definition rgbw.h:21
@ kRGBWDefaultColorTemp
Definition rgbw.h:206
Definition rgbw.h:227
@ Green
<div style='background:#008000;width:4em;height:4em;'></div>
Definition crgb.h:565
@ Red
<div style='background:#FF0000;width:4em;height:4em;'></div>
Definition crgb.h:629
@ Blue
<div style='background:#0000FF;width:4em;height:4em;'></div>
Definition crgb.h:519
@ White
<div style='background:#FFFFFF;width:4em;height:4em;'></div>
Definition crgb.h:653
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:517
#define Serial
Definition serial.h:309