FastLED 3.9.3
Loading...
Searching...
No Matches
MultiArrays.ino
Go to the documentation of this file.
1
4
5// MultiArrays - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on
6// using multiple controllers. In this example, we're going to set up three NEOPIXEL strips on three
7// different pins, each strip getting its own CRGB array to be played with
8
9#include <FastLED.h>
10
11#define NUM_LEDS_PER_STRIP 60
12CRGB redLeds[NUM_LEDS_PER_STRIP];
13CRGB greenLeds[NUM_LEDS_PER_STRIP];
14CRGB blueLeds[NUM_LEDS_PER_STRIP];
15
16// For mirroring strips, all the "special" stuff happens just in setup. We
17// just addLeds multiple times, once for each strip
18void setup() {
19 // tell FastLED there's 60 NEOPIXEL leds on pin 10
20 FastLED.addLeds<NEOPIXEL, 10>(redLeds, NUM_LEDS_PER_STRIP);
21
22 // tell FastLED there's 60 NEOPIXEL leds on pin 11
23 FastLED.addLeds<NEOPIXEL, 11>(greenLeds, NUM_LEDS_PER_STRIP);
24
25 // tell FastLED there's 60 NEOPIXEL leds on pin 12
26 FastLED.addLeds<NEOPIXEL, 12>(blueLeds, NUM_LEDS_PER_STRIP);
27
28}
29
30void loop() {
31 for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
32 // set our current dot to red, green, and blue
33 redLeds[i] = CRGB::Red;
34 greenLeds[i] = CRGB::Green;
35 blueLeds[i] = CRGB::Blue;
36 FastLED.show();
37 // clear our current dot before we move on
38 redLeds[i] = CRGB::Black;
39 greenLeds[i] = CRGB::Black;
40 blueLeds[i] = CRGB::Black;
41 delay(100);
42 }
43
44 for(int i = NUM_LEDS_PER_STRIP-1; i >= 0; i--) {
45 // set our current dot to red, green, and blue
46 redLeds[i] = CRGB::Red;
47 greenLeds[i] = CRGB::Green;
48 blueLeds[i] = CRGB::Blue;
49 FastLED.show();
50 // clear our current dot before we move on
51 redLeds[i] = CRGB::Black;
52 greenLeds[i] = CRGB::Black;
53 blueLeds[i] = CRGB::Black;
54 delay(100);
55 }
56}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:33
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:82
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:67
LED controller for WS2812 LEDs with GRB color order.
Definition FastLED.h:134
@ Green
Definition crgb.h:527
@ Blue
Definition crgb.h:481
@ Red
Definition crgb.h:591
@ Black
Definition crgb.h:479
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39