FastLED 3.9.12
Loading...
Searching...
No Matches
BlinkParallel.ino
#include "FastLED.h"
// How many leds in your strip?
#define NUM_LEDS 256
// Demo of driving multiple WS2812 strips on different pins
// Define the array of leds
CRGB leds[NUM_LEDS]; // Yes, they all share a buffer.
void setup() {
Serial.begin(115200);
//FastLED.addLeds<WS2812, 5>(leds, NUM_LEDS); // GRB ordering is assumed
FastLED.addLeds<WS2812, 1>(leds, NUM_LEDS); // GRB ordering is assumed
FastLED.addLeds<WS2812, 2>(leds, NUM_LEDS); // GRB ordering is assumed
FastLED.addLeds<WS2812, 3>(leds, NUM_LEDS); // GRB ordering is assumed
FastLED.addLeds<WS2812, 4>(leds, NUM_LEDS); // GRB ordering is assumed
delay(1000);
}
void fill(CRGB color) {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = color;
}
}
void blink(CRGB color, int times) {
for (int i = 0; i < times; i++) {
fill(color);
delay(500);
fill(CRGB::Black);
delay(500);
}
}
void loop() {
// Turn the LED on, then pause
blink(CRGB(8,0,0), 1); // blink once for red
blink(CRGB(0,8,0), 2); // blink twice for green
blink(CRGB(0,0,8), 3); // blink thrice for blue
delay(50);
// now benchmark
uint32_t start = millis();
fill(CRGB(8,8,8));
uint32_t diff = millis() - start;
Serial.print("Time to fill and show for non blocking (ms): ");
Serial.println(diff);
delay(50);
start = millis();
fill(CRGB(8,8,8));
diff = millis() - start;
Serial.print("Time to fill and show for 2nd blocking (ms): ");
Serial.println(diff);
}
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