Google

Saturday, November 3, 2007

Line following Coding Using CCS

#include <16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#fuses HS,NOPROTECT,NOWDT,BROWNOUT,PUT,NOLVP
#define motor2 PIN_E0 //MOTOR 1
#define motor1 PIN_E1 //MOTOR 2
#define enable1 PIN_c1// enb 1
#define enable2 PIN_c2 //enb 2
main()
{
while(1)
{
if(!input(PIN_E0)&&(!input(PIN_E1)))
{
output_high(enable1);
output_high(motor1);
output_high(enable2);
output_high(motor2);
delay_ms(1000);
}
else if(input(PIN_E0)&&(!input(PIN_E1)))
{
output_high(enable1);
output_high(motor1);
output_low(enable2);
output_high(motor2);
delay_ms(1000);
}

else if(!input(PIN_E0)&&(input(PIN_E1)))
{
output_low(enable1);
output_high(motor1);
output_high(enable2);
output_high(motor2);
delay_ms(1000);
}
else
{
output_high(enable2);
output_low(motor2);
output_high(enable1);
output_low(motor1);
delay_ms(1000);
}
}

2 comments:

Unknown said...

Hi Caen....is that it!! i thought the code would be much longer! dont you have a schematic that shows how you made your line sensor circuit and how it connects to the pic16F877? thanks

adi kirana said...

Hai Priya...in this robot you have choice to use either foto-electric or infra-red sensor..if you want to use economic sensor,you can see it at infra-red sensor page at my blog.