//
// External Interrupt
// By PEK '2006
//
// Compiler: GCC
// MCU: ATTiny26
// Clock: 1 MHz
//

#define F_CPU 1000000

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

// INT0 ISR
ISR(INT0_vect)
{
	static uint8_t uCntr = 0;

	_delay_ms(10);

	if(!(PINB & _BV(PB6)))	// The input is still low?
	{
		uCntr++;
		PORTA = uCntr;
	}
}


// Main
int main(void)
{
	// Setup Ports
	PORTA = 0xFF;
	DDRA = 0xFF;	// Port A as output
	PORTB = 0x00;
	DDRB = 0x00;	// Port B as input

	MCUCR = _BV(ISC01);	// Falling edge of INT0 generates an interrupt
	GIMSK |= _BV(INT0);	// Enable INT0
	sei();	// Enable global interrupts

	while(1)
	{

	}

	return 1;
}


