#include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 4
// For led chips like WS2812, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
// Clock pin only needed for SPI based chipsets when not using hardware SPI
#define DATA_PIN_1 11 //Red led strip
#define DATA_PIN_2 10 //Blue led strip
#define DATA_PIN_3 5 //green led strip
#define DATA_PIN_4 6 //Yellow led strip
// Define the array of leds
CRGB leds[NUM_LEDS];
CRGB leds_1[NUM_LEDS];
CRGB leds_2[NUM_LEDS];
CRGB leds_3[NUM_LEDS];
long prev=0;
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN_1>(leds, NUM_LEDS); // GRB ordering is assumed
FastLED.addLeds<NEOPIXEL, DATA_PIN_2>(leds_1, NUM_LEDS); // GRB ordering is assumed
FastLED.addLeds<NEOPIXEL, DATA_PIN_3>(leds_2, NUM_LEDS); // GRB ordering is assumed
FastLED.addLeds<NEOPIXEL, DATA_PIN_4>(leds_3, NUM_LEDS); // GRB ordering is assumed
}
void loop() {
// Turn the LED on, then pause
prev=millis();
while ((millis()-prev)<10000)
{
if ((millis()-prev)<500)
{
red_on();
blue_on();
green_on();
yellow_on();
}
else if ((millis()-prev)<1000)
{
red_off();
blue_off();
green_off();
yellow_off();
}
else if ((millis()-prev)<1500)
{
red_on();
blue_on();
green_on();
yellow_on();
}
else if ((millis()-prev)<2000)
{
red_off();
blue_off();
green_off();
yellow_off();
}
else if ((millis()-prev)<2500)
{
red_on();
blue_on();
green_on();
yellow_on();
}
else if ((millis()-prev)<3000)
{
red_off();
blue_off();
green_off();
yellow_off();
}
else if ((millis()-prev)<3500)
{
blue_on();
green_on();
yellow_on();
}
else if ((millis()-prev)<4000)
{
blue_off();
green_off();
yellow_off();
}
//===================================================
else if ((millis()-prev)<4500)
{
blue_on();
green_on();
yellow_on();
}
else if ((millis()-prev)<5000)
{
blue_off();
green_off();
yellow_off();
}
else if ((millis()-prev)<5500)
{
blue_on();
green_on();
yellow_on();
}
else if ((millis()-prev)<6000)
{
blue_off();
green_off();
yellow_off();
}
else if ((millis()-prev)<6500)
{
blue_on();
yellow_on();
}
else if ((millis()-prev)<7000)
{
blue_off();
yellow_off();
}
else if ((millis()-prev)<7500)
{
yellow_on();
}
else if ((millis()-prev)<8000)
{
yellow_off();
}
//===================================================
else if ((millis()-prev)<8500)
{
yellow_on();
}
else if ((millis()-prev)<9000)
{
yellow_off();
}
}
delay(3000);
}
void red_on()
{
leds[0] = CRGB::Red;
leds[1] = CRGB::Red;
leds[2] = CRGB::Red;
leds[3] = CRGB::Red;
leds[0] = CRGB::Red;
FastLED.show();
}
void blue_on()
{
leds_1[0] = CRGB::Blue;
leds_1[1] = CRGB::Blue;
leds_1[2] = CRGB::Blue;
leds_1[3] = CRGB::Blue;
FastLED.show();
}
void green_on()
{
leds_2[0] = CRGB::Green;
leds_2[1] = CRGB::Green;
leds_2[2] = CRGB::Green;
leds_2[3] = CRGB::Green;
FastLED.show();
}
void yellow_on()
{
leds_3[0] = CRGB::Yellow;
leds_3[1] = CRGB::Yellow;
leds_3[2] = CRGB::Yellow;
leds_3[3] = CRGB::Yellow;
FastLED.show();
}
void red_off()
{
// Now turn the LED off, then pause
leds[0] = CRGB::Black;
leds[1] = CRGB::Black;
leds[2] = CRGB::Black;
leds[3] = CRGB::Black;
FastLED.show();
}
void blue_off()
{
leds_1[0] = CRGB::Black;
leds_1[1] = CRGB::Black;
leds_1[2] = CRGB::Black;
leds_1[3] = CRGB::Black;
FastLED.show();
}
void green_off()
{
leds_2[0] = CRGB::Black;
leds_2[1] = CRGB::Black;
leds_2[2] = CRGB::Black;
leds_2[3] = CRGB::Black;
FastLED.show();
}
void yellow_off()
{
leds_3[0] = CRGB::Black;
leds_3[2] = CRGB::Black;
leds_3[3] = CRGB::Black;
leds_3[1] = CRGB::Black;
FastLED.show();
}