white Line following of arduino robot on black background

we are trying to write a white line following program using the arduino robot. The robot is follwing the line but not properly. After following the first curve it is going out of the line and moving in a random fashion. The program is given below

#include<ArduinoRobot.h>
int IRarray;

void setup()
{
Robot.begin();

}

void loop()
{
Robot.updateIR();
{

if(Robot.IRarray[3]>700 & Robot.IRarray[2]>700 & Robot.IRarray[1]>700)
Robot.motorsWrite(100,100);

if(Robot.IRarray[1]<700 & Robot.IRarray[2]>600 & Robot.IRarray[3]>600)
Robot.motorsWrite(150,100);

if(Robot.IRarray[1]<700 & Robot.IRarray[2]<600 & Robot.IRarray[3]>600)
Robot.motorsWrite(180,100);

if(Robot.IRarray[1]>600 & Robot.IRarray[2]>600 & Robot.IRarray[3]<600)
Robot.motorsWrite(100,150);

if(Robot.IRarray[1]>600 & Robot.IRarray[2]<600 & Robot.IRarray[3]<600)

Robot.motorsWrite(100,180);

}

}

please give us some suggestion to solve this problem.

Your &'s need to be &&'s, have a look here.

we have already tried using "&&" . But the robot is not following the line properly. it is following the curves slightly at first but then it is going out of the track.

amir-10_:
we have already tried using “&&” .

Well you should post the code that is at least more correct, since using “&” in that context is definitely wrong and “&&” is definitely right for that purpose.

Maybe you need more sensors…

JimboZA: Your &'s need to be &&'s, have a look here.

I wonder if they really do?

I also wonder what happened to Robot.IRarray[0]

we are trying to do it using 3 sensors only using a thin white track. should we move on to using 5 sensors and a thicker track??

amir-10_: we are trying to do it using 3 sensors only using a thin white track. should we move on to using 5 sensors and a thicker track??

No idea.

What do your debug prints tell you?

Oh, wait . . .