#include <Adafruit_NeoPixel.h>
#define PIN 23 // On Trinket or Gemma, suggest changing this to 1
#define NUMPIXELS 8 // Popular NeoPixel ring size
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 500
void allPixelsOff();
void rotatingColors();
void colorWipe(uint32_t color, int wait);
void theaterChase(uint32_t color, int wait);
void setup()
{
Serial.begin(115200);
pixels.begin();
}
void loop()
{
theaterChase(pixels.Color(209, 86, 203), 50);
// while (Serial.available() > 0)
// {
// String command = Serial.readStringUntil('\n');
// Serial.println(command);
// if (command == "off")
// {
// allPixelsOff();
// }
// else if (command == "rotating")
// {
// rotatingColors();
// }
// else if (command == "wipe")
// {
// colorWipe(pixels.Color(255, 0, 0), 50);
// }
// else if (command == "theater")
// {
// theaterChase(pixels.Color(0, 0, 255), 50);
// }
// }
}
void allPixelsOff()
{
pixels.clear();
pixels.show();
}
void rotatingColors()
{
for (int i = 0; i < NUMPIXELS; i++)
{
pixels.setPixelColor(i, pixels.Color(209, 86, 203));
pixels.show();
delay(DELAYVAL);
pixels.setPixelColor(i, 0);
}
}
void colorWipe(uint32_t color, int wait)
{
for (int i = 0; i < NUMPIXELS; i++)
{
pixels.setPixelColor(i, color);
pixels.show();
delay(wait);
}
}
void theaterChase(uint32_t color, int wait)
{
for (int j = 0; j < 10; j++)
{
for (int q = 0; q < 3; q++)
{
for (int i = 0; i < NUMPIXELS; i = i + 3)
{
pixels.setPixelColor(i + q, color);
}
pixels.show();
delay(wait);
for (int i = 0; i < NUMPIXELS; i = i + 3)
{
pixels.setPixelColor(i + q, 0);
}
}
}
}