#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel pix(20, 2, NEO_GRB + NEO_KHZ800);
void setup()
{
pix.begin();
pix.setBrightness(255);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
}
void loop()
{
if(digitalRead(8) == LOW)
{
for(int i=0; i<20; i++)
pix.setPixelColor(i, pix.Color(0, 255, 0));
pix.show();
}
else if(digitalRead(9) == LOW)
{
for(int i=0; i<20; i++)
pix.setPixelColor(i, pix.Color(255, 0, 0));
pix.show();
delay(500);
for(int i=19; i>=0; i--)
pix.setPixelColor(i, pix.Color(0, 0, 255));
pix.show();
delay(500);
}
else
{
pix.clear();
pix.show();
}
}