// Definir los pines
const int ledPin = 0; // Pin del LED en DDRD
const int buttonPin = 5; // Pin del botón en DDRB (correspondiente al pin 13 en Arduino Uno)
void setup() {
// Configurar el pin del LED como salida (pin 0 en DDRD)
DDRD |= (1 << ledPin);
// Configurar el pin del botón como entrada (pin 5 en DDRB)
DDRB &= ~(1 << buttonPin);
}
void loop() {
// Leemos el estado del botón
if (bit_is_clear(PINB, buttonPin)) {
// Si el botón está presionado, encendemos el LED
PORTD |= (1 << ledPin);
} else {
// Si no, apagamos el LED
PORTD &= ~(1 << ledPin);
}
}