//write a code to blink leds EVEN from 7-0 by pressing 0TH BUTTON
//hardware is same as 1st exp
#include <stdint.h>
#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)
void delay1sec(void){
TCNT1 = 0;
TCCR1A = 0x00;
TCCR1B = 0x05;
while (TCNT1 < 15625);
TCCR1B = 0x00;
}
int main(void){
DDRA = 0xFF;
DDRB = 0x00;
while(1){
if (PINB & 0X01 == 0x01) {
for (int8_t j = 0; j <= 8; j+=2) {
PORTA = (1 << j);
delay1sec();
PORTA = 0x00;
delay1sec();
}
} else {
PORTA = 0x00;
}
}
}