#include <Adafruit_NeoPixel.h>
#define PIN 4
#define NUM_LEDS 360
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show();
}
void loop() {
int ringStartIndex[] = {0, 10, 30, 60, 100, 150, 210, 280}; // Índices de inicio para cada anillo
int ringSizes[] = {10, 20, 30, 40, 50, 60, 70, 80}; // Tamaños de cada anillo
int numRings = 8;
int delayTime = 40; // Tiempo de retardo entre cada anillo
// Recorrido hacia adelante
for (int ring = 0; ring < numRings + 4; ring++) {
// Apagar todos los LEDs antes de encender los siguientes anillos
strip.clear();
for (int i = 0; i < 4; i++) {
if (ring - i >= 0 && ring - i < numRings) {
int currentRing = (ring - i) % numRings; // Asegura que el índice del anillo esté en el rango correcto
int startIndex = ringStartIndex[currentRing];
int ringSize = ringSizes[currentRing];
// Encender el anillo actual
strip.fill(strip.Color(255, 0, 0), startIndex, ringSize); // Color rojo
}
}
strip.show();
delay(delayTime);
}
// Asegurarse de que todos los anillos estén apagados
strip.clear();
strip.show();
delay(delayTime);
// Recorrido hacia atrás
for (int ring = numRings - 1; ring >= -4; ring--) {
// Apagar todos los LEDs antes de encender los siguientes anillos
strip.clear();
for (int i = 0; i < 4; i++) {
if (ring + i >= 0 && ring + i < numRings) {
int currentRing = (ring + i + numRings) % numRings; // Asegura que el índice del anillo esté en el rango correcto
int startIndex = ringStartIndex[currentRing];
int ringSize = ringSizes[currentRing];
// Encender el anillo actual
strip.fill(strip.Color(255, 0, 0), startIndex, ringSize); // Color rojo
}
}
strip.show();
delay(delayTime);
}
// Asegurarse de que todos los anillos estén apagados
strip.clear();
strip.show();
delay(delayTime * 4);
}