#include <avr/io.h>
#include <util/delay.h>



#define bit_get(p,m) ((p) & (m)) 

#define bit_set(p,m) ((p) |= (m)) 

#define bit_clear(p,m) ((p) &= ~(m)) 

#define BIT(x) (0x01 << (x)) 
int main()
{
//SETUP
//Button is on PA3
//LED is PB2

bit_set(PORTA,BIT(3)); //Turn button pullup resistor on by setting PA3(input) high

bit_set(DDRA,BIT(7)); //Enable output on the LED pin (PB2)





//LOOP
while (1)
{
if(bit_get(PINA,BIT(3)))//button is not pushed
{
bit_set(PORTA,BIT(7));//LED is on

}
else // button is pushed
{
bit_set(PORTA,BIT(7));//LED is on
_delay_ms(80);
bit_clear(PORTA,BIT(7));//LED is off
_delay_ms(20);
bit_set(PORTA,BIT(7));//LED is on
_delay_ms(80);
bit_clear(PORTA,BIT(7));//LED is off
_delay_ms(20);
bit_set(PORTA,BIT(7));//LED is on
_delay_ms(80);
bit_clear(PORTA,BIT(7));//LED is off
_delay_ms(20);
bit_set(PORTA,BIT(7));//LED is on
_delay_ms(160);
bit_clear(PORTA,BIT(7));//LED is off
_delay_ms(20);
bit_set(PORTA,BIT(7));//LED is on
_delay_ms(120);
bit_clear(PORTA,BIT(7));//LED is off
_delay_ms(120);
}
} 

}