//Definimos los pines de los LEDs
const int ledPins[] = {15, 2, 4, 5, 18, 19, 21, 22};
// Definimos el pin del potenciómetro
const int potPin = 32;
void setup() {
// Inicializamos los pines de los LEDs como salidas
for (int i = 0; i < 8; i++) {
pinMode(ledPins[i], OUTPUT);
}
// Inicializamos el pin del potenciómetro como entrada
pinMode(potPin, INPUT);
}
void loop() {
// Leemos el valor del potenciómetro
int potValue = analogRead(potPin);
// Mapeamos el valor del potenciómetro a una velocidad de secuencia
int speed = map(potValue, 0, 4095, 50, 500);
// Secuencia de luces
for (int i = 0; i < 8; i++) {
digitalWrite(ledPins[i], HIGH);
delay(speed);
digitalWrite(ledPins[i], LOW);
delay(speed);
}
for (int i = 6; i >= 1; i--) {
digitalWrite(ledPins[i], HIGH);
delay(speed);
digitalWrite(ledPins[i], LOW);
delay(speed);
}
}