//write a code to blink leds odd from 0-1 by pressing 7TH 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; // LEDs output
DDRB = 0x00; // Buttons input
while(1){
if ((PINB & (1 << 6)) == (1 << 6)) { // PB6 pressed
for (int8_t j = 1; j < 8; j += 2) {
PORTA = (1 << j);
delay1sec();
PORTA = 0x00;
delay1sec();
}
} else {
PORTA = 0x00;
}
}
}