FastLED 3.9.12
Loading...
Searching...
No Matches
BlinkParallel.ino
Go to the documentation of this file.
1
5
6#include "FastLED.h"
7
8// How many leds in your strip?
9#define NUM_LEDS 256
10
11// Demo of driving multiple WS2812 strips on different pins
12
13// Define the array of leds
14CRGB leds[NUM_LEDS]; // Yes, they all share a buffer.
15
16void setup() {
17 Serial.begin(115200);
18 //FastLED.addLeds<WS2812, 5>(leds, NUM_LEDS); // GRB ordering is assumed
19 FastLED.addLeds<WS2812, 1>(leds, NUM_LEDS); // GRB ordering is assumed
20 FastLED.addLeds<WS2812, 2>(leds, NUM_LEDS); // GRB ordering is assumed
21 FastLED.addLeds<WS2812, 3>(leds, NUM_LEDS); // GRB ordering is assumed
22 FastLED.addLeds<WS2812, 4>(leds, NUM_LEDS); // GRB ordering is assumed
23 delay(1000);
24}
25
26void fill(CRGB color) {
27 for (int i = 0; i < NUM_LEDS; i++) {
28 leds[i] = color;
29 }
30}
31
32void blink(CRGB color, int times) {
33 for (int i = 0; i < times; i++) {
34 fill(color);
35 FastLED.show();
36 delay(500);
37 fill(CRGB::Black);
38 FastLED.show();
39 delay(500);
40 }
41}
42
43void loop() {
44 // Turn the LED on, then pause
45 blink(CRGB(8,0,0), 1); // blink once for red
46 blink(CRGB(0,8,0), 2); // blink twice for green
47 blink(CRGB(0,0,8), 3); // blink thrice for blue
48
49 delay(50);
50
51
52
53 // now benchmark
54 uint32_t start = millis();
55 fill(CRGB(8,8,8));
56 FastLED.show();
57 uint32_t diff = millis() - start;
58
59 Serial.print("Time to fill and show for non blocking (ms): ");
60 Serial.println(diff);
61
62 delay(50);
63
64 start = millis();
65 fill(CRGB(8,8,8));
66 FastLED.show();
67 FastLED.show();
68
69 diff = millis() - start;
70 Serial.print("Time to fill and show for 2nd blocking (ms): ");
71 Serial.println(diff);
72}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:45
central include file for FastLED, defines the CFastLED class/object
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:94
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:79
WS2812 controller class.
Definition FastLED.h:190
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54
@ Black
Definition crgb.h:496