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

//Port A data register
#define LED_PORT PORTA
//Port A data direction register
#define LED_DIR  DDRA
//Port A input pins
#define LED_PINS PINA
//Pin number where LED is connected
#define LED_PIN  (1 << PA3)
//Same for the button
#define BTN_PORT PORTA
#define BTN_DIR  DDRA
#define BTN_PINS PINA
#define BTN_PIN  (1 << PA7)

int main(void){
  //Enable pull-up resistor after tristate (see datasheet 10.1.3)
  LED_PORT |= LED_PIN;
  //Configure pin A3 (i.e. the one for the LED) as output and turn it off
  LED_DIR |= LED_PIN;
  LED_PORT &= ~LED_PIN;

  //Enable pull-up resistor, since the button is connected to ground
  BTN_PORT |= BTN_PIN;
  //Configure button pin as input
  BTN_DIR &= ~BTN_PIN;

  while(1){
    _delay_ms(10);
    if(!(BTN_PINS & BTN_PIN)){
      //Toggle LED
      LED_PORT ^= LED_PIN;
    } else {
      LED_PORT &= ~LED_PIN;
    }
  }
}