#include <FastLED.h>
#define NUM_STRIPS 4
//----------------------Here you can change the number of LEDs for each strip--------------------
#define NUM_LEDS_1 50
#define NUM_LEDS_2 50
#define NUM_LEDS_3 50
#define NUM_LEDS_4 50
// defining LED strip pins
#define LED_PIN_1 2
#define LED_PIN_2 3
#define LED_PIN_3 4
#define LED_PIN_4 5
// defining Button pins
int Btn1=14, Btn2=15;
int Strp1=0, Strp2=1 ,Strp3=2 ;
int D1=10, D2=50, D3=50;
int i1, i2,i3;
unsigned long prev1, prev2,prev3;
int P1=2, P2=4,P3=4;
CRGB leds[NUM_STRIPS][50];
void setup() {
FastLED.addLeds<WS2812B, LED_PIN_1, GRB>(leds[0], NUM_LEDS_1);
FastLED.addLeds<WS2812B, LED_PIN_2, GRB>(leds[1], NUM_LEDS_2);
FastLED.addLeds<WS2812B, LED_PIN_3, GRB>(leds[2], NUM_LEDS_3);
FastLED.addLeds<WS2812B, LED_PIN_4, GRB>(leds[3], NUM_LEDS_4);
FastLED.setBrightness(50);
pinMode(Btn1, INPUT_PULLUP);
pinMode(Btn2, INPUT_PULLUP);
}
void loop() {
//-----------------------------------Reading Button 1---------------------
// Strip_1();
// Strip_2();
// Strip_3();
for(int j=0; j<NUM_LEDS_1; j++)
{leds[Strp1][j] = CRGB::Red;}
FastLED.show();
delay(50);
}
void Strip_1()
{
if (i1 < (NUM_LEDS_1/P1))
{
if (millis()-prev1<D1)
{
for(int j=i1*P1; j<(i1*P1)+P1; j++)
{leds[Strp1][j] = CRGB::Red;}
FastLED.show();
}
else if (millis()-prev1>D1)
{
for(int j=i1*P1; j<(i1*P1)+P1; j++)
{ leds[Strp1][j] = CRGB::Black;}
FastLED.show(); prev1=millis();
i1++;
if (i1==(NUM_LEDS_1/P1)) i1=0;
} }
}
void Strip_1_OFF()
{ for (int j = 0; j < NUM_LEDS_1; j++) {
leds[Strp1][j] = CRGB::Black;}
FastLED.show(); }
void Strip_2()
{
if (i2 < (NUM_LEDS_2/P2))
{
if (millis()-prev2<D2)
{
for(int j=i2*P2; j<(i2*P2)+P2; j++)
{leds[Strp2][j] = CRGB::Red;}
FastLED.show();
}
else if (millis()-prev2>D2)
{
for(int j=i2*P2; j<(i2*P2)+P2; j++)
{ leds[Strp2][j] = CRGB::Black;}
FastLED.show(); prev2=millis();
i2++;
if (i2==(NUM_LEDS_2/P2)) i2=0;
} }
}
void Strip_2_OFF()
{ for (int j = 0; j < NUM_LEDS_2; j++) {
leds[Strp2][j] = CRGB::Black;}
FastLED.show(); }
void Strip_3()
{
if (i3 < (NUM_LEDS_3/P3))
{
if (millis()-prev3<D3)
{
for(int j=i3*P3; j<(i3*P3)+P3; j++)
{leds[Strp3][j] = CRGB::Red;}
FastLED.show();
}
else if (millis()-prev3>D3)
{
for(int j=i3*P3; j<(i3*P3)+P3; j++)
{ leds[Strp3][j] = CRGB::Black;}
FastLED.show(); prev3=millis();
i3++;
if (i3==(NUM_LEDS_3/P3)) i3=0;
} }
}
void Strip_3_OFF()
{ for (int j = 0; j < NUM_LEDS_3; j++) {
leds[Strp3][j] = CRGB::Black;}
FastLED.show(); }