/// ArrayOfLedArrays - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on
// using multiple controllers. In this example, we're going to set up three NEOPIXEL strips on three
// different pins, each strip getting its own CRGB array to be played with, only this time they're going
// to be all parts of an array of arrays.
#include <FastLED.h>
#include <mechButton.h> // The base LC_baseTools mechButton class.
#define BTN_A 5 // Pin top self button
#define BTN_B 4 // Pin middle self button
#define BTN_C 3 // Pin bottom self button
mechButton aButton(BTN_A); // Set button one to pin BTN_A.
mechButton bButton(BTN_B); // Set button two to pin BTN_B.
mechButton cButton(BTN_C); // Set button three to pin BTN_C.
#define LED_COLOR GRB
#define NUM_STRIPS 3
#define NUM_LEDS_PER_STRIP 12
CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];
// For mirroring strips, all the "special" stuff happens just in setup. We
// just addLeds multiple times, once for each strip
void setup() {
// tell FastLED there's 12 NEOPIXEL leds on pin 8
FastLED.addLeds<NEOPIXEL, 8>(leds[0], NUM_LEDS_PER_STRIP);
// tell FastLED there's 12 NEOPIXEL leds on pin 7
FastLED.addLeds<NEOPIXEL, 7>(leds[1], NUM_LEDS_PER_STRIP);
// tell FastLED there's 12 NEOPIXEL leds on pin 6
FastLED.addLeds<NEOPIXEL, 6>(leds[2], NUM_LEDS_PER_STRIP);
Serial.begin(9600); // Fire up our serial monitor thing.
pinMode(LED_COLOR,OUTPUT); // Set up the LED pin for output.
aButton.setCallback(myCallback); // Set up our callback. (Also calls hookup() for idling.)
}
// This is the guy that's called when the button changes state.
void myCallback(void) {
Serial.print("Button just became ");
if (aButton.trueFalse()) {
Serial.println("true!");
} else {
Serial.println("false!");
}
}
void loop() {
// This outer loop will go over each strip, one at a time
for(int x = 0; x < NUM_STRIPS; x++) {
// This inner loop will go over each led in the current strip, one at a time
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
leds[x][i] = LED_COLOR;
FastLED.show();
leds[x][i] = CRGB::Black;
delay(100);
}
}
}