#include <Adafruit_NeoPixel.h>
#define PIN 6 // Define the pin where the data line is connected
#define NUM_LEDS 4 // Define the number of NeoPixel LEDs
// Initialize the NeoPixel object
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin(); // Initialize the strip
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
for (int led = 0; led < NUM_LEDS; led++) {
// Turn on the current LED with green color
strip.setPixelColor(led, strip.Color(0, 255, 0));
strip.show();
delay(500);
strip.setPixelColor(led, strip.Color(0, 0, 0)); // Turn off the current LED
strip.show();
delay(100); // Short delay before moving to the next LED
// Turn on the current LED with red color
strip.setPixelColor(led, strip.Color(255, 0, 0));
strip.show();
delay(500);
strip.setPixelColor(led, strip.Color(0, 0, 0)); // Turn off the current LED
strip.show();
delay(100); // Short delay before moving to the next LED
// Turn on the current LED with blue color
strip.setPixelColor(led, strip.Color(0, 0, 255));
strip.show();
delay(500);
strip.setPixelColor(led, strip.Color(0, 0, 0)); // Turn off the current LED
strip.show();
delay(100); // Short delay before moving to the next LED
}
}