hi,
i am using 18f4550 and c18 compiler.one sensor is connected to the port E0.motors are coneected to rc1 rd0 and rd3 rd4.
problem statement:whenever the sensor detects a black line or switches off, integer i has to increment by 1(all other times the sensor is high).
PATH:black tapes are arranged horizontally with gap of 20 cm on white surface
here goes my program.......
define an PORTEbits.RE0
void main()
{
int i=0;
TRISE = 0b00000001;
TRISC = 0;
TRISD = 0;
while(1)
{
while(an==1)
{
PORTC = 0b00000000; //run motors forward
PORTD = 0b00001001;
}
if(an==0)
{
i++;
}
while(i==3)
{
PORTC = 0b00000000; //turn left
PORTD = 0b00000101;
some delay;
i=0;
}
}
}
problem:the bot is running properly.....but it is not responding to the integer i(the direction is not changing)