#include <inttypes.h>
#include <avr/io.h>
#define F_CPU 16000000UL
#include <util/delay.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))
#define is_low(x, y) ((x & _BV(y)) == 0)
int main()
{
DDRB = 0xff;
PORTB = 0x00;
DDRD = 0x00;
PORTD = 0xff;
while(1)
{
uint8_t i;
for(i = 0; i < 2; i++)
{
if(i == 0)
{
sbi(PORTB, PB0);
}
else if(i == 1)
{
if(is_low(PIND, PD0))
{
cbi(PORTB, PB0);
}
else
{
sbi(PORTB, PB0);
}
}
_delay_ms(100);
}
}
return 0;
}