// Control de LED con botón
// El LED se enciende mientras el botón esté presionado
const int boton = 2; // Pin del botón
const int led = 17; // Pin del LED
void setup() {
pinMode(boton, INPUT); //Configura el pin del botón como entrada
//RECORDAR CONECTAR LA RESISTENCIA PULL DOWN EN EL CIRCUITO!!!!
pinMode(led, OUTPUT); // Configurar el pin del LED como salida
digitalWrite(led, LOW); // Inicializar el LED apagado
}
void loop() {
// Leer el estado del botón
int estado_boton = digitalRead(boton);
// if -> Si el botón está presionado
if (estado_boton == HIGH) {
digitalWrite(led, HIGH); // LED ON
}
else { //else -> si no
digitalWrite(led, LOW); // LED OFF
}
delay(1000); // Esperar 1 segundo
}