// Declaración de variables
int led = 4;
int button = 15;
int state = LOW; // Estado inicial del LED (apagado)
int lastBtnState = LOW; // Estado anterior del botón
int btnState; // Estado actual del botón
void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT);
digitalWrite(led, state);
}
void loop() {
btnState = digitalRead(button);
// Verificar si el botón ha sido presionado y soltado
if (btnState == HIGH && lastBtnState == LOW) {
delay(10);
state = !state;
digitalWrite(led, state);
}
lastBtnState = btnState;
}