#include #include int main(void) {DDRD=0x00; // PORTD declared as input port PORTD=0xFF; // PORTD initialized DDRC=0XFF; // PORTC declared as output port PORTC=0x00; // PORTC initialized while(1) { if(!(PIND&0x01)) // PIN D0 is used as input { _delay_ms(500); while(!(PIND&0x01)) PORTC=0b00000010; // motor rotates in one particular direction } else if(!(PIND&0x02)) // PIN D1 is used as another input { _delay_ms(500); while(!(PIND&0x02)) PORTC=0b00000001; // motor rotates in another direction } else { PORTC=0x00; // Stop motor } } }