#include <Adafruit_NeoPixel.h>
#define LED_PIN 2
#define NUM_LEDS 49
#define DELAY_TIME 100
#define MAX_RUN_TIME 3000
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
unsigned long lastUpdateTime = 0;
void setup() {
strip.begin();
strip.show();
}
void loop() {
flashingRandomLights();
}
//All code for flashingRandomLights
void flashingRandomLights() {
unsigned long currentTime = millis();
if (currentTime - lastUpdateTime >= DELAY_TIME) {
fillRandomColors();
lastUpdateTime = currentTime;
}
if (currentTime >= MAX_RUN_TIME) {
clearLEDs();
while (true) {}
}
}
void fillRandomColors() {
for(int i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, random(256), random(256), random(256));
}
strip.show();
}
void clearLEDs() {
for(int i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, 0);
}
strip.show();
}