#define F_CPU 20000000 #include #include uint8_t counter; void setup() { PORTA.DIRCLR |= PIN7_bm; //Set PA7 to input PORTA.PIN7CTRL |= PORT_PULLUPEN_bm; //Set pullup resistor on PA7 PORTA.DIRSET |= PIN6_bm; //Set PA6 as output } void loop() { //check to see if PA7 is pulled low if(~PORTA.IN & PIN7_bm){ //wait until PA7 returns high while(~PORTA.IN & PIN7_bm){ _delay_ms(5); counter++; if(counter >= 5){ //set PA6 to LOW PORTA.OUT |= PIN6_bm; _delay_ms(1000); //set PA6 to HIGH PORTA.OUT &= ~PIN6_bm; } } } }