//connect 8 LEDs to portA glow 0-7 with delay and reverse it like 7-0 with delay
//same hardware as before ass 1 and 2
#include <stdint.h>
#define DDRA (*(volatile uint8_t*)0x21)
#define PORTA (*(volatile uint8_t*)0x22)
void delay1sec(void){
TCNT1 = 0;
TCCR1A = 0x00;
TCCR1B = 0x05;
while (TCNT1 < 15625);
TCCR1B = 0x00;
}
void setup() {
DDRA = 0xFF;
}
void loop() {
for (uint8_t i = 0; i < 8; i++) {
PORTA = (1 << i);
delay1sec();
}
for (int8_t i = 7; i >= 0; i--) {
PORTA = (1 << i);
delay1sec();
}
}