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