int pulsador1 = A0;
int led1 = 8;
int pulsador2 = A1;
void setup() {
pinMode(pulsador1, INPUT_PULLUP); // Activa la resistencia pull-up interna
pinMode(pulsador2, INPUT_PULLUP); // Activa la resistencia pull-up interna
pinMode(led1, OUTPUT);
DDRD = 0xFF; // Configura el puerto D como salida excepto el pin 0
}
void loop() {
if (digitalRead(pulsador1) == LOW) { // El botón está presionado
// Primer recorrido del péndulo
PORTD = 128; delay(500); // Led 1
PORTD = 64; delay(40); // Led 2
PORTD = 0b00100000; delay(40); // Led 3
PORTD = 0x10; delay(40); // Led 4
PORTD = 0x08; delay(40); // Led 5
PORTD = 0b00000100; delay(40); // Led 6
PORTD = 2; delay(40); // Led 7
PORTD = 0b00000001; delay(40); // Led 8
} else if (digitalRead(pulsador2) == LOW) {
PORTD = 0b00000001; delay(40); // Led 8
PORTD = 2; delay(40); // Led 7
PORTD = 0b00000100; delay(40); // Led 6
PORTD = 0x08; delay(40); // Led 5
PORTD = 0x10; delay(40); // Led 4
PORTD = 0b00100000; delay(40); // Led 3
PORTD = 64; delay(40); // Led 2
PORTD = 128; delay(500); // Led 1
// Apaga todos los LEDs cuando el botón no está presionado
} else
PORTD = 0;
}