#include #define F_CPU 20000000 #include int buttonState = 0; int main(void) { CPU_CCP = CCP_IOREG_gc; // Un-protect protected I/O registers - allow clock changes CLKCTRL_MCLKCTRLB = 0; // disable clock prescaler - clock is now equal to system clock - 20MHz VPORTA_DIR |= PIN7_bm; VPORTA_IN |= PIN4_bm; while(1) { buttonState = VPORTA_IN & PIN4_bm; // If button is not pressed if (buttonState > 0) { PORTA_OUTTGL = PIN7_bm; // Toggle PORTB pin 0 _delay_ms(1000); // gives a 1 Hz toggle rate } } }