#include <Arduino.h>
#include "FastLED.h"
// #define NUM_LEDS 620
#define NUM_LEDS (35 * 2 + 12 * 2 + 6 * 4)
#define Data_Pin 16
#define chipset WS2812B
#define BRIGHTNESS 255 //set the strips brightness from 1 to 255
#define OffSet 310
CRGB leds[NUM_LEDS];
CRGBSet strips[] = {
CRGBSet(leds + 0, 35),
CRGBSet(leds + 35, 12),
CRGBSet(leds + 47, 35),
CRGBSet(leds + 82, 12),
CRGBSet(leds + 94, 6),
CRGBSet(leds + 100, 6),
CRGBSet(leds + 106, 6),
CRGBSet(leds + 112, 6),
// CRGBSet(leds + 118, 6),
// CRGBSet(leds + 124, 6),
// CRGBSet(leds + 130, 6),
// CRGBSet(leds + 136, 6),
// CRGBSet(leds + 142, 6),
// CRGBSet(leds + 148, 6),
// CRGBSet(leds + 154, 6),
// CRGBSet(leds + 160, 6),
// CRGBSet(leds + 166, 6),
// CRGBSet(leds + 172, 6),
// CRGBSet(leds + 178, 6),
// CRGBSet(leds + 184, 6),
// CRGBSet(leds + 190, 5),
// CRGBSet(leds + 195, 5),
// CRGBSet(leds + 200, 5),
// CRGBSet(leds + 205, 5),
// CRGBSet(leds + 210, 5),
// CRGBSet(leds + 215, 5),
// CRGBSet(leds + 220, 5),
// CRGBSet(leds + 225, 5),
// CRGBSet(leds + 230, 5),
// CRGBSet(leds + 235, 5),
// CRGBSet(leds + 240, 5),
// CRGBSet(leds + 245, 5),
// CRGBSet(leds + 250, 5),
// CRGBSet(leds + 255, 5),
// CRGBSet(leds + 260, 5),
// CRGBSet(leds + 265, 5),
// CRGBSet(leds + 270, 5),
// CRGBSet(leds + 275, 5),
// CRGBSet(leds + 280, 5),
// CRGBSet(leds + 285, 5),
// CRGBSet(leds + 290, 5),
// CRGBSet(leds + 295, 5),
// CRGBSet(leds + 300, 5),
// CRGBSet(leds + 305, 5),
// CRGBSet(leds + OffSet + 0, 35),
// CRGBSet(leds + OffSet + 35, 12),
// CRGBSet(leds + OffSet + 47, 35),
// CRGBSet(leds + OffSet + 82, 12),
// CRGBSet(leds + OffSet + 94, 6),
// CRGBSet(leds + OffSet + 100, 6),
// CRGBSet(leds + OffSet + 106, 6),
// CRGBSet(leds + OffSet + 112, 6),
// CRGBSet(leds + OffSet + 118, 6),
// CRGBSet(leds + OffSet + 124, 6),
// CRGBSet(leds + OffSet + 130, 6),
// CRGBSet(leds + OffSet + 136, 6),
// CRGBSet(leds + OffSet + 142, 6),
// CRGBSet(leds + OffSet + 148, 6),
// CRGBSet(leds + OffSet + 154, 6),
// CRGBSet(leds + OffSet + 160, 6),
// CRGBSet(leds + OffSet + 166, 6),
// CRGBSet(leds + OffSet + 172, 6),
// CRGBSet(leds + OffSet + 178, 6),
// CRGBSet(leds + OffSet + 184, 6),
// CRGBSet(leds + OffSet + 190, 5),
// CRGBSet(leds + OffSet + 195, 5),
// CRGBSet(leds + OffSet + 200, 5),
// CRGBSet(leds + OffSet + 205, 5),
// CRGBSet(leds + OffSet + 210, 5),
// CRGBSet(leds + OffSet + 215, 5),
// CRGBSet(leds + OffSet + 220, 5),
// CRGBSet(leds + OffSet + 225, 5),
// CRGBSet(leds + OffSet + 230, 5),
// CRGBSet(leds + OffSet + 235, 5),
// CRGBSet(leds + OffSet + 240, 5),
// CRGBSet(leds + OffSet + 245, 5),
// CRGBSet(leds + OffSet + 250, 5),
// CRGBSet(leds + OffSet + 255, 5),
// CRGBSet(leds + OffSet + 260, 5),
// CRGBSet(leds + OffSet + 265, 5),
// CRGBSet(leds + OffSet + 270, 5),
// CRGBSet(leds + OffSet + 275, 5),
// CRGBSet(leds + OffSet + 280, 5),
// CRGBSet(leds + OffSet + 285, 5),
// CRGBSet(leds + OffSet + 290, 5),
// CRGBSet(leds + OffSet + 295, 5),
// CRGBSet(leds + OffSet + 300, 5),
// CRGBSet(leds + OffSet + 305, 5),
};
const uint8_t numStrips = sizeof(strips) / sizeof(*strips);
uint8_t pattern[numStrips] = {1, };
uint8_t fadePosition[numStrips] = {};
uint8_t fadeCounter[numStrips] = {};
CRGB colorarry[] = {CRGB::Red, CRGB::White, CRGB::Blue, CRGB::Green};
const uint8_t sz_colorarry = sizeof(colorarry) / sizeof(*colorarry);
void fadeOut(uint8_t strip) {
strips[strip].fadeToBlackBy(2);
}
void fadeIn(uint8_t strip) {
uint8_t fadeInSpeed = 16;
// choose the colour based on which strip
CRGB col = colorarry[strip % sz_colorarry];
// advance the fade
fadeCounter[strip] = qadd8(fadeCounter[strip], fadeInSpeed);
// find the current pixel's address
CRGB *pixel = &strips[strip].leds[fadePosition[strip]];
// plot colour to the current pixel
*pixel = col;
// and fade it
(*pixel).fadeToBlackBy(255 - fadeCounter[strip]);
// if this pixel is fully faded in
if (fadeCounter[strip] == 255) {
if (fadePosition[strip] + 1 < strips[strip].size()) {
// move the to next pixel if any remain on this strip
fadePosition[strip]++;
fadeCounter[strip] = 0;
} else {
// move to next strip once this strip is fully lit
pattern[strip] = 0;
fadePosition[strip] = 0;
fadeCounter[strip] = 0;
pattern[(strip + 1) % numStrips] = 1;
}
}
}
void setup() {
// delay(2000); // power-up safety delay
FastLED.addLeds<chipset, Data_Pin, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
//FastLED.setMaxPowerInVoltsAndMilliamps(5,1000);
}
void loop() {
for (uint8_t strip = 0; strip < numStrips; strip++) {
switch (pattern[strip]) {
case 0:
fadeOut(strip);
break;
case 1:
fadeIn(strip);
break;
}
}
FastLED.show();
}