#include <Adafruit_NeoPixel.h>
#define LED_PIN 3
#define NUM_LEDS 16
#define LEFT 1
#define RIGHT 0
Adafruit_NeoPixel leds = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
bool isDone = false;
void setup()
{
leds.begin();
leds.setBrightness(255);
leds.clear();
leds.show();
}
void loop()
{
if (!isDone)
{
showLeds(255, 0, 0, RIGHT);
showLeds(0, 0, 255, LEFT);
showLeds(255, 255, 255, RIGHT);
isDone = true;
}
}
void showLeds(byte r, byte g, byte b, byte direction)
{
if (direction == LEFT)
{
for(int i = NUM_LEDS - 1; i >= 0; i--)
{
leds.setPixelColor(i, leds.Color(r, g, b));
leds.show();
delay(200);
}
}
else
{
for(int i = 0; i < NUM_LEDS; i++)
{
leds.setPixelColor(i, leds.Color(r, g, b));
leds.show();
delay(200);
}
}
}