#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#define PPIN0 A0
#define PPIN1 A1
#define PPIN2 A2
#define PPIN3 A3
#define NUMPIXELS 17
Adafruit_NeoPixel pRing0 = Adafruit_NeoPixel(NUMPIXELS, PPIN0, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pRing1 = Adafruit_NeoPixel(NUMPIXELS, PPIN1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pRing2 = Adafruit_NeoPixel(NUMPIXELS, PPIN2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pRing3 = Adafruit_NeoPixel(NUMPIXELS, PPIN3, NEO_GRB + NEO_KHZ800);
int delayval = 60;
void startUp()
{
serialRings("BLUE");
}
void serialRings(String startColor)
{
for(int i=0;i<NUMPIXELS;i++)
{
setColor(0 , i, startColor);
delay(delayval); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMPIXELS;i++)
{
setColor(1 , i, startColor);
delay(delayval); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMPIXELS;i++)
{
setColor(2 , i, startColor);
delay(delayval); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMPIXELS;i++)
{
setColor(3 , i, startColor);
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
void serialRingsWhiteStar(String startColor)
{
for(int i=0;i<NUMPIXELS;i++)
{
setColor(0 , i+1, "WHITE");
setColor(0 , i, startColor);
delay(delayval); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMPIXELS;i++)
{
setColor(1, i+1, "WHITE");
setColor(1 , i, startColor);
delay(delayval); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMPIXELS;i++)
{
setColor(2 , i+1, "WHITE");
setColor(2 , i, startColor);
delay(delayval); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMPIXELS;i++)
{
setColor(3 , i+1, "WHITE");
setColor(3 , i, startColor);
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
void setup()
{
pRing0.begin();
pRing1.begin();
pRing2.begin();
pRing3.begin();
startUp();
}
void loop()
{
serialRingsWhiteStar("ROBOTICRED");
serialRingsWhiteStar("BLUE");
}
void setColor(int ra, int pa, String color)
{
uint8_t c0;
uint8_t c1;
uint8_t c2;
if (color == "WHITE")
{
c0 = 255;
c1 = 255;
c2 = 255;
}
else if (color == "BLACK")
{
c0 = 0;
c1 = 0;
c2 = 0;
}
else if (color == "ROBOTICRED")
{
c0 = 205;
c1 = 0;
c2 = 39;
}
else if (color == "BALTICBLUE")
{
c0 = 0;
c1 = 27;
c2 = 68;
}
else if (color == "BLUE")
{
c0 = 0;
c1 = 0;
c2 = 255;
}
else
{
c0 = 0;
c1 = 0;
c2 = 0;
}
//ra = ring address (0-3)
//pa = pixel address
if (ra == 0 )
{
pRing0.setPixelColor(pa, pRing0.Color(c0,c1,c2)); // Moderately bright green color.
pRing0.show(); // This sends the updated pixel color to the hardware.
}
else if (ra == 1 )
{
pRing1.setPixelColor(pa, pRing0.Color(c0,c1,c2)); // Moderately bright green color.
pRing1.show(); // This sends the updated pixel color to the hardware.
}
else if (ra == 2 )
{
pRing2.setPixelColor(pa, pRing0.Color(c0,c1,c2)); // Moderately bright green color.
pRing2.show(); // This sends the updated pixel color to the hardware.
}
else if (ra == 3 )
{
pRing3.setPixelColor(pa, pRing0.Color(c0,c1,c2)); // Moderately bright green color.
pRing3.show(); // This sends the updated pixel color to the hardware.
}
else
{
}
}