#include <Adafruit_NeoPixel.h>
#define PIN 6 // Pin to which the NeoPixel ring is connected
#define NUMPIXELS 24 // Number of LEDs in the NeoPixel ring
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pixels.begin(); // Initialize NeoPixel strip
pixels.setBrightness(200); // Set brightness (0-255)
}
void loop() {
colorChaseClockwise(0xFF0000, 50); // Red
colorChaseClockwise(0x00FF00, 50); // Green
colorChaseClockwise(0xFFFF00, 50); // Yellow
colorChaseAntiClockwise(0xFF0000, 50); // Red
colorChaseAntiClockwise(0x00FF00, 50); // Green
colorChaseAntiClockwise(0xFFFF00, 50); // Yellow
}
void colorChaseClockwise(uint32_t color, int wait) {
for(int j=0; j<NUMPIXELS; j++) {
pixels.setPixelColor(j, color); // Set color for the current pixel
pixels.show(); // Update the NeoPixel strip with new color
delay(wait); // Wait before updating the next pixel
pixels.setPixelColor(j, 0); // Turn off the current pixel
delay(wait); // Wait before moving to the next pixel
}
}
void colorChaseAntiClockwise(uint32_t color, int wait) {
for(int j=NUMPIXELS-1; j>=0; j--) {
pixels.setPixelColor(j, color); // Set color for the current pixel
pixels.show(); // Update the NeoPixel strip with new color
delay(wait); // Wait before updating the next pixel
pixels.setPixelColor(j, 0); // Turn off the current pixel
delay(wait); // Wait before moving to the next pixel
}
}