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

// Blink several times upon button click.

#define blink_delay 250
#define blink_repeat 5

int main(void)
{
	// Setup: button on PA3 (10), LED on PA7 (6)
	//PORTA = _BV(PA3);	// Activate button
	DDRA = _BV(PA7);	// Enable output on LED pin

	// Loop
	while (1)
	{
		if (PINA & _BV(PA3)) {
			PORTA = 0; // turn LED off
		}
		else
		{
			unsigned char i;
			for (i=0; i<blink_repeat; ++i) {
				PORTA |= _BV(PA7);	// turn LED on
				_delay_ms(blink_delay);
				PORTA = 0;			// turn LED off
				_delay_ms(blink_delay);
			}
		}

	}
}
 