Analog Reading of QRD1114 to implement on a while loop

Hi, My name is Kenneth it is my first time posting seeking for help

my apologies if anything I type below is unclear

Today i was doing programming with the Arduino Mega using QRD1114. i got the analog reading

i type in the code like this
void loop
{
while(frontsensor<=0&&frontSensor>=400)
{
MotorRun();
}
}
*MotorRun is just a function for the H-bridge to enable both wheel to go forward

why does it not exit the loop at all?

Do I need to do something like Calibrating ?

Are there 2 different frontsensor variables in your while loop?
Try using the || (or) instead of && (and).

Have you printed out the analog readings so you know what ranges to expect?

Yes i have printed out the analog Reading and i have set it, my robot is able to do line tracking :slight_smile: with the analog reading i got.

using the same reading i program it in a while loop .

nope there is only one variables

while(frontsensor<=0&&frontSensor>=400)

Assuming that both variables are actually frontsensor, this while loop will never execute. The value of the variable can't be both <= 0 AND >=400. As electricteardown suggested, it would make more sense if you meant OR in this case.

Can you post your complete program. Use code tags (the "#" button above the row of smileys). Copy and paste it from the Arduino IDE to avoid transcription errors.

Thanks

Ray

sorry it's is while(frontsensor<=0&&frontsensor>=400)

the Sensor is not caps it is sensor paste the code here tomorrow thanks for the help