You are on page 1of 2

void main() { CMCON = 0x07; ADCON1 = 0x06; TRISA=1; TRISB=0xF0; while(1) { { if(PORTA==0) PORTB=0x00; delay_ms(10); } { if(PORTA.

F0) PORTB=0x09; delay_ms(10); } { if(PORTA.F1) PORTB=0x04; delay_ms(10); } { if(PORTA.F2) //RIGHT MOTOR ON & TURN RIGHT //LEFT MOTOR ON & TURN LEFT //BOTH MOTORS MOVE FORWARD DIRECTION //Initally All bits off // To turn off comparators // To turn off ADC //Sets port A as an input //sets pin F0,F1,F3,F4 as an Output

PORTB=0x01; delay_ms(100); } { if(PORTA.F3) PORTB=0x06; delay_ms(10); } } } //BOTH MOTORS MOVE REVERSE DIRECTION

You might also like