FastLED 3.9.15
Loading...
Searching...
No Matches
BlinkParallel.ino
Go to the documentation of this file.
1
5
6#include "FastLED.h"
7
8
9#if SKETCH_HAS_LOTS_OF_MEMORY
10// How many leds in your strip?
11#define NUM_LEDS 256
12#else
13#define NUM_LEDS 16
14#endif
15
16// Demo of driving multiple WS2812 strips on different pins
17
18// Define the array of leds
19CRGB leds[NUM_LEDS]; // Yes, they all share a buffer.
20
21void setup() {
22 Serial.begin(115200);
23 //FastLED.addLeds<WS2812, 5>(leds, NUM_LEDS); // GRB ordering is assumed
24 FastLED.addLeds<WS2812, 1>(leds, NUM_LEDS); // GRB ordering is assumed
25 FastLED.addLeds<WS2812, 2>(leds, NUM_LEDS); // GRB ordering is assumed
26 FastLED.addLeds<WS2812, 3>(leds, NUM_LEDS); // GRB ordering is assumed
27 FastLED.addLeds<WS2812, 4>(leds, NUM_LEDS); // GRB ordering is assumed
28 delay(1000);
29}
30
31void fill(CRGB color) {
32 for (int i = 0; i < NUM_LEDS; i++) {
33 leds[i] = color;
34 }
35}
36
37void blink(CRGB color, int times) {
38 for (int i = 0; i < times; i++) {
39 fill(color);
40 FastLED.show();
41 delay(500);
43 FastLED.show();
44 delay(500);
45 }
46}
47
48void loop() {
49 // Turn the LED on, then pause
50 blink(CRGB(8,0,0), 1); // blink once for red
51 blink(CRGB(0,8,0), 2); // blink twice for green
52 blink(CRGB(0,0,8), 3); // blink thrice for blue
53
54 delay(50);
55
56
57
58 // now benchmark
59 uint32_t start = millis();
60 fill(CRGB(8,8,8));
61 FastLED.show();
62 uint32_t diff = millis() - start;
63
64 Serial.print("Time to fill and show for non blocking (ms): ");
65 Serial.println(diff);
66
67 delay(50);
68
69 start = millis();
70 fill(CRGB(8,8,8));
71 FastLED.show();
72 FastLED.show();
73
74 diff = millis() - start;
75 Serial.print("Time to fill and show for 2nd blocking (ms): ");
76 Serial.println(diff);
77}
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
WS2812 controller class.
Definition FastLED.h:218
@ 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