// Definimos los pines donde están conectados el LED y el botón
int LED_PIN=2;
int BOTON=4;
int ESTADO_BOTON=0;
// Variable para almacenar el estado del botón
void setup() {
// Inicializamos los pines del LED y del botón
pinMode(LED_PIN, OUTPUT);
pinMode(BOTON, INPUT);
}
void loop() {
// Leemos el estado del botón
ESTADO_BOTON = digitalRead(BOTON);
// Verificamos si el botón ha sido presionado
if (ESTADO_BOTON == HIGH) {
digitalWrite(LED_PIN, HIGH);
}
else {
digitalWrite(LED_PIN, LOW);
}
}