//write a code to blink leds one by one by pressing pushbutton 3
//hardware is same as 1st exp
#define PINA (*(volatile uint8_t*)0x20)
#define DDRA (*(volatile uint8_t*)0x21)
#define PORTA (*(volatile uint8_t*)0x22)
#define PINB (*(volatile uint8_t*)0x23)
#define DDRB (*(volatile uint8_t*)0x24)
#define PORTB (*(volatile uint8_t*)0x25)
volatile uint32_t i,j;
void delay1sec(void){
TCNT1 = 0;
TCCR1A = 0x00;
TCCR1B = 0x05; // prescaler 1024
while (TCNT1 < 15625);
TCCR1B = 0x00;
}
int main(void){
DDRA = 0xFF;
DDRB = 0x00;
while(1){
if((PINB & 0x08) == 0x08){
for(j = 0; j<8; j++){
PORTA = (1<<j);
delay1sec();
PORTA = 0x00;
delay1sec();
}
} else {
PORTA = 0x00;
}
}
}