#define F_CPU 8000000
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

ISR(INT0_vect)
{
	TCCR0B = 0b00000111;
	_delay_ms(10000);
	TCCR0B = 0;
	if (TCNT0<5)
	{
		PORTB |= 0x08;
		_delay_ms(2000);
		PORTB &= 0xF7;
	}
	else if (TCNT0<10)
	{
		PORTB |= 0x10;
		_delay_ms(2000);
		PORTB &= 0xEF;
	}
	else if (TCNT0>30)
	{
		PORTB |= 0x01;
		_delay_ms(5000);
		PORTB &= 0xFE;
	}
}

int main(void)
{
	DDRB = 0b11101;
	PORTB = 0b00010;
	MCUCR = 0b00000010;
	GTCCR = 0b10000000;
	asm("sei");
	while (1)
	{
		PORTB |= 0x19;
		_delay_ms(500);
		PORTB &= 0xE6;
		asm ("sleep");
	}
}
