// blink sketch
// anders haldin
// 16/03 2015
// licens CC

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


#define LED1_ON (PORTA |= (1<<PA0))
#define LED1_OFF (PORTA &= ~(1<<PA0))

#define LED2_ON (PORTA |= (1<<PA1))
#define LED2_OFF (PORTA &= ~(1<<PA1))

#define K1 ((PINA & (1<<PINA7)) == 0)
#define K2 ((PINB & (1<<PINB2)) == 0)


int main()
{

	DDRA &= ~(1<<DDA7);  //K1, set as input
	DDRB &= ~(1<<DDB2);  //K2

	DDRA |= (1<<DDA0);  //LED1, set IO as output.
	DDRA |= (1<<DDA1);  //LED2

	LED1_OFF;
	LED2_OFF;

while(1)
{
	if(K1)
	{
		LED2_ON;
		LED1_OFF;
	}
	else if(K2)
	{
		LED1_ON;
		LED2_OFF;
	}


}


}//closeing main