#include <FastLED.h>
#define DATA_PIN 2
#define NUM_LEDS 50
#define MAX_BRIGHTNESS 255
#define BRIGHTNESS 100 // MAX is 255
#define LED_TYPE WS2811
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600);
FastLED.addLeds<LED_TYPE, DATA_PIN, RGB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
CRGB black = CRGB::Black;
CRGB red = CRGB::Red;
CRGB pink = CRGB::Magenta;
CRGB blue = CRGB::Blue;
CRGB yellow = CRGB::LightYellow;
CRGB white = CRGB::White;
CRGB purp = CRGB::Purple;
int per[26] ={0,1,4,2,5,8,13,9,14,21,15,22,16,26,27,33,28,34,38,42,39,43,45,47,46,48};
//at 23 (start up right) and 27 (start left on left perimeter) are points of change
int full[49]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48};
// right half from 1 to 27
//left half from 23 to 49
void loop() {
//full_flash(array, from, to, color, delay); Every led lights up at same time (1 color)
//onebyone_add(array, from, to, color1, color2, delay); Every led in section of array one by one with 2 diff colors
//fade_two(array, from, to, numcolor, numcolor, skipval, delay); section fade through 2 colors
//10 red, 50 yellow, 80 green, 120 green blue, 180 lavander, 200 purple, 245 pink
//colorhue(skipdist, delay); fades through entire rainbow
//flicker(array, from, to, color1, color2, minDelay, maxDelay); light up at random delay speeds
//alt_blink(array, from, to, color1, color2, onTime, offTime);
// onebyone_add(full,0,49,white,blue,50);
fade_two(full, 0, 48, 500, 150, 5, 25);
onebyone_add(full, 0, 48, blue, white, 25);
fade_two(full, 0, 48, 500, 255, 5, 25);
onebyone_add(full, 0, 48, white, pink, 25);
full_flash(full, 0, 48, white, 25);
colorhue(10, 25);
full_flash(per,0,25,white,30);
}
void full_flash(int sec[], int from, int to, CRGB color, int dly) {
for (int x = from; x <= to; x++) {
leds[sec[x]]=color;
FastLED.delay(dly);
}
}
void onebyone_add(int sec[], int from, int to, CRGB color1, CRGB color2, int dly){
for (int x = from; x <= to; x++ ) {
leds[sec[x]] = color1;
FastLED.delay(dly);
leds[sec[x+2]] = color2;
FastLED.delay(dly);
}
}
void fade_two(int sec[], int from, int to, int color1, int color2, int skipval, int dly) {
int hue[2]= {color1,color2};
for (int c = 0; c < 2; c++) {
for (int v = 255; v >= 0; v=v-skipval) {
for (int x = from; x <= to; x++) {
leds[sec[x]] = CHSV(hue[c], 255, v);
}
FastLED.delay(dly);
}
}
}
//fades through each color for all leds
void colorhue(int skipdist, int dly) {
int h = 255;
int s = 255;
int v = 255;
while (h>0){
for (int x = 0; x < NUM_LEDS; x++) {
leds[x] = CHSV(h,s,v);
}
FastLED.delay(dly);
h=h-skipdist;
}
}
void alt_blink(int sec[], int from, int to, CRGB color1, CRGB color2, int onTime, int offTime) {
for (int x = from; x <= to; x++) {
leds[sec[x]] = color1;
FastLED.show();
delay(onTime);
leds[sec[x]] = color2;
FastLED.show();
delay(offTime);
}
}
//lights up at random flickers
void flicker(int sec[], int from, int to, CRGB color1, CRGB color2, int minDelay, int maxDelay) {
for (int x = from; x <= to; x++) {
leds[sec[x]] = color1;
FastLED.delay(random(minDelay, maxDelay));
leds[sec[x]] = color2;
FastLED.delay(random(minDelay, maxDelay));
}
}