#include <Adafruit_NeoPixel.h>
#define LED_PIN1 3 // Pin for the first NeoPixel strip
#define LED_COUNT1 32 // Number of NeoPixels in the first strip
#define LED_PIN2 6 // Pin for the second NeoPixel strip
#define LED_COUNT2 32 // Number of NeoPixels in the second strip
Adafruit_NeoPixel strip1(LED_COUNT1, LED_PIN1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2(LED_COUNT2, LED_PIN2, NEO_GRB + NEO_KHZ800);
void setup() {
// Initialize both NeoPixel strips
strip1.begin();
strip2.begin();
// Set the brightness to full
strip1.setBrightness(255);
strip2.setBrightness(255);
// Create rainbows on each strip
for (int i = 0; i < LED_COUNT1; i++) {
int r = 255 - i * 8;
int g = i * 8;
int b = 0;
strip1.setPixelColor(i, strip1.Color(r, g, b));
}
strip1.show();
// Create a copy of the first strip for use in setup()
Adafruit_NeoPixel strip1copy(strip1);
for (int i = 0; i < LED_COUNT2; i++) {
int r = 255 - i * 8;
int g = i * 8;
int b = 0;
strip2.setPixelColor(i, strip2.Color(r, g, b));
}
strip2.show();
}
void loop() {
// Move the first rainbow to the right
for (int i = LED_COUNT1 - 1; i > 0; i--) {
strip1.setPixelColor(i, strip1.getPixelColor(i - 1));
}
strip1.setPixelColor(0, strip1.Color(0, 0, 0));
// Move the second rainbow to the left
for (int i = 0; i < LED_COUNT2 - 1; i++) {
strip2.setPixelColor(i, strip2.getPixelColor(i + 1));
}
strip2.setPixelColor(LED_COUNT2 - 1, strip2.Color(0, 0, 0));
strip1.show();
strip2.show();
delay(100);
}