#include <Adafruit_NeoPixel.h>
#define PIN_NEO_PIXEL 2 // Arduino pin that connects to NeoPixel
#define NUM_PIXELS 8 // The number of LEDs (pixels) on NeoPixel
Adafruit_NeoPixel NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL, NEO_GRB + NEO_KHZ800);
struct RGB {
int red;
int green;
int blue;
};
int pixel = 0;
const int maxPixel = NUM_PIXELS - 1;
int sekIndex;
int delaySec = 20;
RGB sek[] = {
{255, 193, 0},
{255, 154, 0},
{255, 116, 0},
{255, 77, 0},
{255, 0, 0}
};
int sekCount = sizeof(sek) / sizeof(sek[0]);
void setup() {
NeoPixel.begin();
// put your setup code here, to run once:
}
void loop() {
delaySec = random(66) + 20;
// if (sekIndex >= sekCount) {
// sekIndex = 0;
// }
// sekIndex = sekIndex + 1;
sekIndex = random(sekCount);
pixel = random(maxPixel + 1);
// if (pixel > maxPixel) {
// pixel = -1;
// }
// pixel = pixel + 1;
NeoPixel.setPixelColor(pixel, NeoPixel.Color(sek[sekIndex].red, sek[sekIndex].green, sek[sekIndex].blue));
// put your main code here, to run repeatedly:
NeoPixel.show();
delay(delaySec);
}