reg the black line tracing

we are facing the following problem in the black line tracing

we are using 3 whiteline sensors, but the problem is that the width of the line that we trace is of lesser width than that of the distance between the 2 sensors … we can neither adjust the width of the line nor the distance between the sensors…so the condition that we are facing is that ,the bot gets struck if we are deviated off the course even a little… sensing all the 3 sensors to be white

here is the code

void traceBlackLine(){
unsigned char left=0;
unsigned char center=0;
unsigned char right=0;
unsigned char black=0x18;

while(1){

left=ADC_Conversion(WLS_LEFT);
center=ADC_Conversion(WLS_CENTER);
right=ADC_Conversion(WLS_RIGHT);

if(left<black && center <black && right<black){ /// W W W

move(stop);

} else if(left<black && center <black && right>black){ //W W B
move(SOFT_RIGHT_BACK); // Adjust towards right
_delay_ms(50);
} else if(left<black && center >black && right<black){ // W B W
move(FORWARD);
_delay_ms(50);
} else if(left<black && center >black && right>black){ // W B B

forward_mm(60);
return;
} else if(left>black && center <black && right<black){ // B W W
move(SOFT_LEFT_BACK);
_delay_ms(50);
} else if(left>black && center >black && right<black){ // B B W
forward_mm(60);
return;
} else if(left>black && center >black && right>black){ // B B B
forward_mm(60);
return;
}

}
}
please do help me …

Hi,
What does your 3rd sensor do?
A picture of your line follower and the line, would help.

Thanks Tom..... :slight_smile:

It sounds like you need to modify your software so that it is not triggered by the absence of a black line on the centre sensor but, instead, it waits to see the black line under one of the outer sensors.

...R

i am looking for a suggestion regarding the modification of the code

shan_raja:
i am looking for a suggestion regarding the modification of the code

You have posted code without using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don’t do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons.
If you have already posted without using code tags, open your message and select “modify” from the pull down menu labelled, “More”, at the lower left corner of the message. Highlight your code by selecting it (it turns blue), and then click on the “</>” icon at the upper left hand corner. Click on the “Save” button. Code tags can also be inserted manually in the forum text using the code and /code metatags.

Unless the sketch is too large, it’s better if you post your code, rather than attach it. When it’s attached, we have to download it, create a folder then open your code in our IDE. And afterwards, the folder remains unless we navigate to the “Temp” folder and manually remove it. It’s much easier to just view the code in your post.

Many questions can be answered by reading the documentation which is provided with the IDE, available under the help tab, or online here.

There are many other things that programmers do to make their code understandable. Please do them, as a courtesy to the members who volunteer their time to help you here. One is to use a standard indentation to clearly show the code blocks. Never put more than one statement per line. Place any brackets by themselves on a separate line. Before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.

shan_raja:
i am looking for a suggestion regarding the modification of the code

I made a suggestion in Reply #2.

If you want someone to write the code for you then you should ask in the Gigs and Collaborations section and be prepared to pay.

Otherwise make an attempt at your own code and if you can't get it to work post the code and a description of what it actually does and what you want it to do.

...R