const int botonPin = 4;
const int ledPins[] = {5, 6, 7, 8};
const int numLeds = sizeof(ledPins) / sizeof(ledPins[0]);
const int delayTime = 200;
void setup() {
pinMode(botonPin, INPUT_PULLUP); // Usamos resistencia pull-up interna
// Configurar LEDs como salida
for (int i = 0; i < numLeds; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
// Si el botón está presionado (LOW)
if (digitalRead(botonPin) == LOW) {
for (int i = 0; i < numLeds; i++) {
digitalWrite(ledPins[i], HIGH);
delay(delayTime);
digitalWrite(ledPins[i], LOW);
delay(delayTime);
}
}
}