#include <Adafruit_NeoPixel.h>
#define PIXDATPIN 2 // data pin
#define SIDECOUNT 8 // number of sides
#define PIXPERSIDE 8 // pixels per side
#define PIXELS SIDECOUNT * PIXPERSIDE // total number of pixels
#define MAXBRIGHT 255 // determine power use
Adafruit_NeoPixel lamp(PIXELS, PIXDATPIN, NEO_GRB + NEO_KHZ800);
#define SINGLEREV 8000 // milliseconds per revolution
int side;
int RED = 255, GRN = 255, BLU = 63; // change colors for holidays or time of day
void setup() {
lamp.begin(); // start the object
lamp.clear(); // clear the color buffer
lamp.setBrightness(MAXBRIGHT); // set maximum brightness
}
void loop() {
if (side++ == SIDECOUNT - 1) // cycle through sides
side = 0;
lamp.show(); // display last buffer (clear)
for (byte pixel = 0; pixel < PIXPERSIDE; pixel++) { // light all pixels on one side
// using "+0" and "/ 1" to keep code aligned
lamp.setPixelColor(((side + 0) % 8) * PIXPERSIDE + pixel, lamp.Color(RED / 2, GRN / 2, BLU / 2));
lamp.setPixelColor(((side + 1) % 8) * PIXPERSIDE + pixel, lamp.Color(RED / 1, GRN / 1, BLU / 1));
lamp.setPixelColor(((side + 2) % 8) * PIXPERSIDE + pixel, lamp.Color(RED / 2, GRN / 2, BLU / 2));
}
lamp.show(); // display colors
delay(SINGLEREV / SIDECOUNT); // divide revolution by number of sides
lamp.clear(); // clear buffer (but do not yet display buffer)
}