//Presiona botón enciende LED
//Vuelve a presionar botón y se apaga el LED
int led = 8;
int boton = 7;
int estadoBoton = 0;
int estadoAnterior = 0;
int estadoLed = 0;
void setup() {
pinMode(led, OUTPUT);
pinMode(boton, INPUT);
}
void loop() {
estadoBoton = digitalRead(boton);
// Detecta cuando se presiona el botón
if (estadoBoton == HIGH && estadoAnterior == LOW) {
estadoLed = !estadoLed; // Cambia el estado del LED
delay(200); // Pequeño anti-rebote
}
digitalWrite(led, estadoLed);
estadoAnterior = estadoBoton;
}