#include <Adafruit_NeoPixel.h>
#define LED_COUNT 24 // Number of LEDs in each ring
#define LED_PIN_R1 2 // Pin connected to the Data-In of the first ring
#define LED_PIN_R2 3 // Pin connected to the Data-In of the second ring
Adafruit_NeoPixel r1(LED_COUNT, LED_PIN_R1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel r2(LED_COUNT, LED_PIN_R2, NEO_GRB + NEO_KHZ800);
void setup() {
r1.begin();
r2.begin();
randomSeed(analogRead(0)); // Seed the random number generator
}
void loop() {
chaseClockwise(r1);
chaseAnticlockwise(r2);
}
void chaseClockwise(Adafruit_NeoPixel &ring) {
for (int i = 0; i < ring.numPixels(); i++) {
int r = random(256); // Random red component (0-255)
int g = random(256); // Random green component (0-255)
int b = random(256); // Random blue component (0-255)
ring.setPixelColor(i, r, g, b);
ring.show();
delay(100); // Adjust the chase speed (milliseconds)
ring.setPixelColor(i, 0); // Turn off the current LED
}
}
void chaseAnticlockwise(Adafruit_NeoPixel &ring) {
for (int i = ring.numPixels() - 1; i >= 0; i--) {
int r = random(256); // Random red component (0-255)
int g = random(256); // Random green component (0-255)
int b = random(256); // Random blue component (0-255)
ring.setPixelColor(i, r, g, b);
ring.show();
delay(100); // Adjust the chase speed (milliseconds)
ring.setPixelColor(i, 0); // Turn off the current LED
}
}