#include <avr/io.h>
#define sbi(x, y) x |= _BV(y)
#define cbi(x, y) x &= ~(_BV(y))
#define tbi(x, y) x ^= _BV(y)
#define is_high(x, y) ((x & _BV(y)) == _BV(y))
int main()
{
DDRB = 0xff;
PORTB = 0x00;
DDRD = 0x00;
PORTD = 0xff;
while(1)
{
if(is_high(PIND, PD0) && is_high(PIND, PD1))
{
cbi(PORTB, PB0);
cbi(PORTB, PB1);
cbi(PORTB, PB2);
sbi(PORTB, PB3);
}
else if(is_high(PIND, PD0) && !is_high(PIND, PD1))
{
cbi(PORTB, PB0);
sbi(PORTB, PB1);
cbi(PORTB, PB2);
cbi(PORTB, PB3);
}
else if(!is_high(PIND, PD0) && is_high(PIND, PD1))
{
cbi(PORTB, PB0);
cbi(PORTB, PB1);
sbi(PORTB, PB2);
cbi(PORTB, PB3);
}
else if(!is_high(PIND, PD0) && !is_high(PIND, PD1))
{
sbi(PORTB, PB0);
cbi(PORTB, PB1);
cbi(PORTB, PB2);
cbi(PORTB, PB3);
}
}
return 0;
}