#include <Adafruit_NeoPixel.h>
// Declare a NeoPixel strip object with the specified number of pixels and pin number
#define NUM_PIXELS 8
Adafruit_NeoPixel strip(NUM_PIXELS, 6, NEO_GRB + NEO_KHZ800);
void setup() {
// Initialize the NeoPixel strip
strip.begin();
// Set all pixels to off
strip.clear();
// Show the changes on the strip
strip.show();
}
void loop() {
// Loop through each pixel in the strip
for (int i = 0; i < NUM_PIXELS; i++) {
// Calculate the color values for the pixel
int r = (i * 255) / (NUM_PIXELS - 1);
int b = 255 - r;
// Set the pixel to the calculated color
strip.setPixelColor(i, strip.Color(r, 0, b));
}
// Show the changes on the strip
strip.show();
// Delay for a short time
delay(100);
}