#include <Adafruit_NeoPixel.h>
#define NUM_PIXELS 7 // Replace with the number of Neopixels you have
#define PIXEL_PIN 6 // Replace with the pin connected to the Neopixels
Adafruit_NeoPixel pixels(NUM_PIXELS, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
unsigned long previousMillis = 0;
const long interval = 100; // Adjust the interval to control the speed of the chase effect
int delayTime = 500; // Initial delay time
int speedIncrement = 50; // Amount to increment the speed
void setup() {
pixels.begin();
pixels.show(); // Initialize all pixels to off
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
// Clear all pixels
for (int i = 0; i < NUM_PIXELS; i++) {
pixels.setPixelColor(i, 0);
}
// Set the chase effect
for (int i = NUM_PIXELS - 1; i >= 0; i--) {
pixels.setPixelColor(i, pixels.Color(0, 0, 255)); // Blue color
pixels.show();
delay(delayTime); // Use the delayTime variable instead of a fixed delay value
pixels.setPixelColor(i, 0); // Clear the previous pixel
}
// Increase the speed gradually
delayTime -= speedIncrement;
if (delayTime < 0) {
delayTime = 10; // Make sure the delayTime doesn't go below 10
}
}
}