#include <Adafruit_NeoPixel.h>
// Pin Definitions
#define PIN_1 2 // GP2
#define PIN_2 3 // GP3
// Number of LEDs per strip
#define NUM_PIXELS 8
// NeoPixel Objects
Adafruit_NeoPixel strip1(NUM_PIXELS, PIN_1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2(NUM_PIXELS, PIN_2, NEO_GRB + NEO_KHZ800);
void setup() {
strip1.begin();
strip2.begin();
strip1.show(); // Initialize all pixels to 'off'
strip2.show();
}
void loop() {
rainbowCycle(strip1, 10); // Run rainbow on strip 1
rainbowCycle(strip2, 10); // Run rainbow on strip 2
}
// Function to display a rainbow effect
void rainbowCycle(Adafruit_NeoPixel &strip, int wait) {
for (int j = 0; j < 256; j++) {
for (int i = 0; i < strip.numPixels(); i++) {
int pixelHue = (i * 256 / strip.numPixels() + j) & 255;
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue * 65536L / 256)));
}
strip.show();
delay(wait);
}
}