#include <stdint.h>
#include <stddef.h>
#include <avr/io.h>
#define F_CPU 20000000UL
#include <util/delay.h>
#include <stdbool.h>
//~ #define BAUD 9600
//~ #include <util/setbaud.h>
#include <avr/interrupt.h>

uint8_t volatile status = 0;

ISR(INT1_vect){
	status = 1;
	//~ PCORT0 = 1;
}

int main(){

    //~ PORTD |= (1 << PORTD2);    // turn On the Pull-up
    // PD2 is now an input with pull-up enabled
    
	
	EICRA |= 0x0F;	// External Interrupt Control Register
					// INT0 on rising edge
	EIMSK |= 0x03;	// External Interrupt Mask Register
					// Enable INT0 for interrupt
	
	SREG |= 0x80;	// Status Register
					// Enable global interrupts
			
	//~ PCICR |= 0x04;	// Pin Change Interrupt Control Register
					//~ // Enabled PCINT[23;16] -> Pin 13,12,11,6,5,4,3,2
	//~ PCIFR |= 0x04;	// Pin Change Interrupt Flag Register
	
	//~ PCMSK2 = 0xff;	// Pin Change Mask Register 2
					//~ // Enabled PCINT[23;16] (Single Pins)
	DDRC = 0xff;
	
	
	
	while(1){
		if(status){
			PORTC ^= 0x01;
			status = 0;
		}
		PORTC ^= 0x02;
	}
	return 0;
}
