#include "FastLED.h"
// LEDs pin
#define DATA_PIN5 A5
#define DATA_PIN4 A4
#define DATA_PIN3 A3
#define DATA_PIN2 A2
// LED brightness
#define BRIGHTNESS 250
#define NUM_LEDS 3
// Define the array of leds
CRGB leds5[NUM_LEDS];
CRGB leds4[NUM_LEDS];
CRGB leds3[NUM_LEDS];
CRGB leds2[NUM_LEDS];
void UpdateStrip(CRGB *Inled, int Speed, int NumLeds);
void setup() {
FastLED.addLeds<WS2812, DATA_PIN5,GRB>(leds5, NUM_LEDS);
FastLED.addLeds<WS2812, DATA_PIN4,GRB>(leds4, NUM_LEDS);
FastLED.addLeds<WS2812, DATA_PIN3,GRB>(leds3, NUM_LEDS);
FastLED.addLeds<WS2812, DATA_PIN2,GRB>(leds2, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
#define MIN_BRIGHTNESS 0
#define MAX_BRIGHTNESS BRIGHTNESS
#define HUE_COLOR 100 // red color
#define SPEED_FADE 5 //speed of effect
//int a = millis();
// byte b = triwave8 (a/SPEED_FADE);
// byte breath = ease8InOutCubic (b);
// breath = map (breath,0,255, MIN_BRIGHTNESS, MAX_BRIGHTNESS);
// fill_solid(leds5, NUM_LEDS, CHSV(HUE_COLOR, 255, breath));
//fill_gradient(leds,NUM_LEDS,CHSV(0,255,MIN_BRIGHTNESS),CHSV(0,255,breath), CHSV(0,255,breath), CHSV(0,255,MIN_BRIGHTNESS),LONGEST_HUES); // uncomment this to smooth gradient looking effect
// adjust_gamma();
UpdateStrip(leds2,5,3,0,1); //RED
UpdateStrip(leds3,5,3,90,1);//120/(360/255)); //GREEN
UpdateStrip(leds4,5,3,160,1);//240/(360/255)); //BLUE
UpdateStrip(leds5,5,3,60,1);//60/(360/255)); //60Yellow
// UpdateStrip(leds2,5,3,0,0); //RED
// UpdateStrip(leds3,5,3,0,1);//120/(360/255)); //GREEN
// UpdateStrip(leds4,5,3,160,0);//240/(360/255)); //BLUE
// UpdateStrip(leds5,5,3,160,1);//60/(360/255)); //60Yellow
FastLED.delay(1);
delay(100);
}
//void UpdateStrip(CRGB *Inled, int SPEED_FADE, int NUM_LEDS){
void UpdateStrip(CRGB *Inled, int Speed, int NumLeds, int HueColor, bool UseGamma){
int a = millis();
byte b = triwave8 (a/Speed);
byte breath = ease8InOutCubic (b);
breath = map (breath,0,255, MIN_BRIGHTNESS,MAX_BRIGHTNESS);//MIN_BRIGHTNESS, MAX_BRIGHTNESS);
fill_solid(Inled, NumLeds, CHSV(HueColor, 255, breath));
//fill_gradient(leds,NUM_LEDS,CHSV(0,255,MIN_BRIGHTNESS),CHSV(0,255,breath), CHSV(0,255,breath), CHSV(0,255,MIN_BRIGHTNESS),LONGEST_HUES); // uncomment this to smooth gradient looking effect
if (UseGamma){
for (uint16_t i = 0; i < NumLeds; i++)
{
Inled[i].r = dim8_video(Inled[i].r);
Inled[i].g = dim8_video(Inled[i].g);
Inled[i].b = dim8_video(Inled[i].b);
}
}
}