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