#include <Adafruit_NeoPixel.h>
#define NUMSTRIPES 4
Adafruit_NeoPixel stripes[NUMSTRIPES];
// input pins Neopixel is attached to
int pins[] = {2, 3, 4, 5};
#define NUMPIXELS 12 // number of neopixels in strip
int palette[6][3] ={
{140, 80, 0},
{10, 40, 180},
{35, 20, 0},
{5, 10, 60},
{50, 26, 0},
{10, 15, 63}
};
byte effects[4][24][12] = {
{
{ 0,0,0,0,0,0,1,1,1,1,1,1 },
{ 1,0,0,0,0,0,0,1,1,1,1,1 },
{ 1,1,0,0,0,0,0,0,1,1,1,1 },
{ 1,1,1,0,0,0,0,0,0,1,1,1 },
{ 1,1,1,1,0,0,0,0,0,0,1,1 },
{ 1,1,1,1,1,0,0,0,0,0,0,1 },
{ 1,1,1,1,1,1,0,0,0,0,0,0 },
{ 0,1,1,1,1,1,1,0,0,0,0,0 },
{ 0,0,1,1,1,1,1,1,0,0,0,0 },
{ 0,0,0,1,1,1,1,1,1,0,0,0 },
{ 0,0,0,0,1,1,1,1,1,1,0,0 },
{ 0,0,0,0,0,1,1,1,1,1,1,0 },
{ 0,0,0,0,0,0,1,1,1,1,1,1 },
{ 1,0,0,0,0,0,0,1,1,1,1,1 },
{ 1,1,0,0,0,0,0,0,1,1,1,1 },
{ 1,1,1,0,0,0,0,0,0,1,1,1 },
{ 1,1,1,1,0,0,0,0,0,0,1,1 },
{ 1,1,1,1,1,0,0,0,0,0,0,1 },
{ 1,1,1,1,1,1,0,0,0,0,0,0 },
{ 0,1,1,1,1,1,1,0,0,0,0,0 },
{ 0,0,1,1,1,1,1,1,0,0,0,0 },
{ 0,0,0,1,1,1,1,1,1,0,0,0 },
{ 0,0,0,0,1,1,1,1,1,1,0,0 },
{ 0,0,0,0,0,1,1,1,1,1,1,0 }
},
{
{ 0,0,0,0,0,0,0,0,0,0,0,0 },
{ 1,0,0,0,0,0,0,0,0,0,0,0 },
{ 1,1,0,0,0,0,0,0,0,0,0,0 },
{ 1,1,1,0,0,0,0,0,0,0,0,0 },
{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= 0; //part of effect size
int numray = 0; //num ray in wheel
int alpha = 0;
int stp = 0; //step of effect
int steppos = 0; //step for stripe position
int numsteps = 0; //number of steps in effects
bool stripeleft = false; //leff or right stripe
bool raysync = true; //ray synchronized
void setup() {
Serial.begin(9600);
for (int s = 0; s < NUMSTRIPES; s++) {
stripes[s] = Adafruit_NeoPixel(NUMPIXELS, pins[s], NEO_GRB + NEO_KHZ800);
// Initialize the NeoPixel library.
stripes[s].begin();
}
numsteps = sizeof(effects[numeffect])/sizeof(effects[numeffect][0]);
b = numsteps / NUMSTRIPES * 2;
}
void loop() {
for (int s = 0; s < NUMSTRIPES; s++) {
//sleft = s % 2;
if (raysync){
numray = 0;
} else {
numray = floor(s / 2);
}
steppos = (stp + numray * b) % numsteps;
Serial.println(steppos);
for (int i = 0; i < NUMPIXELS; i++) {
// effects used palette and matrix
redColor = palette[effects[numeffect][steppos][i]][0];
greenColor = palette[effects[numeffect][steppos][i]][1];
blueColor = palette[effects[numeffect][steppos][i]][2];
// stripes.Color takes RGB values, from 0,0,0 up to 255,255,255
stripes[s].setPixelColor(i, stripes[s].Color(redColor, greenColor, blueColor));
//Serial.print(i);
// This sends the updated pixel color to the hardware.
stripes[s].show();
}
}
stp++;
if (stp >= numsteps){
stp = 0;
}
// Delay for a period of time (in milliseconds).
delay(delayval);
// running colors
/*
setColor();
for (int i = 0; i < NUMPIXELS; i++) {
for (int s = 0; s < NUMSTRIPES; s++) {
// stripes.Color takes RGB values, from 0,0,0 up to 255,255,255
stripes[s].setPixelColor(i, stripes[s].Color(redColor, greenColor, blueColor));
Serial.print(i);
// This sends the updated pixel color to the hardware.
stripes[s].show();
}
Serial.println();
// Delay for a period of time (in milliseconds).
delay(delayval);
}
*/
}
// setColor()
// picks random values to set for RGB
void setColor() {
redColor = random(10, 150);
greenColor = random(10, 150);
blueColor = random(10, 150);
}