Line following robot

Hello , I just started using arduino , and as you may know i’m a noob so i need some tips on making a line following robot , i got the sensors , motor drivers , and the brain an arduino uno R3 , so whats the problem ? well the problem is the program everytime i tried to test it always fails so can anyone help me ? there is the file attached so please help me , thank you

sorry for not adding information in the first post,
so it doesn’t follow the line somehow
I will get the schematic as soon as i can

line_follower.ino (1.94 KB)

it always fails

What do you mean? Does it not compile? Does it compile and do nothing? Or not follow the line? Or or or....

Probably also a good idea to post a schematic of your circuitry- Arduino pins, motor connections, etc etc

Your code is small enough to be posted here - no need for an attachment.
That’s a fairly unusual style of semicolon placement - where did you pick that up from?

I’d start by adding some serial debug prints, to find out what your robot is observing and how it is reacting - debugging by just observing the behaviour can be frustrating when there’s such a huge disparity between processor speed and the speed of mechanics.

int leftLDR1 = A1;                                   //left LDR attached to analog pin 1       
int rightLDR1 = A0;                                 //right LDR attached to analog pin 0
int leftLDR2 = A2;
int rightLDR2 = A3;
int leftValue1;                                            //this variable is used to store the analog value returned from the left LDR
int rightValue1;                                            //this variable is used to store the analog value returned from the right LDR
int leftValue2;
int rightValue2;
int leftmotor = 2;                                          //create a servo object for the left servo
int rightmotor = 3;                                         //create a servo object for the left servo

void setup()
{
;pinMode(leftLDR1, INPUT);
;pinMode(rightLDR1, INPUT);
;pinMode(leftLDR2, INPUT);
;pinMode(rightLDR2, INPUT);
;pinMode(leftmotor, OUTPUT);
;pinMode(rightmotor, OUTPUT);
}

void loop()
{
  rightValue1 = analogRead(rightLDR1);                    //store value from A0 into the variable rightValue
  leftValue1 = analogRead(leftLDR1);                      //store value from A1 into the variable leftValue
  rightValue2 = analogRead(rightLDR2);                    
  leftValue2 = analogRead(leftLDR2);

{
{
 if(rightValue1 = leftValue1){
   ;analogWrite(leftmotor, 225)
   ;analogWrite(rightmotor, 225 )
 ;}
  else
  {
    if(leftValue1 > rightValue1){
      ;analogWrite(rightmotor, 225)
      ;analogWrite(leftmotor, 0)
    ;}
    else
    {
      if(rightValue1 < leftValue1){
      ;analogWrite(rightmotor, 0)
      ;analogWrite(leftmotor, 225)
    ;}
  ;}
  if(rightValue2 > leftValue2)
  {
    ;analogWrite(rightmotor, 225)
    ;analogWrite(leftmotor, 0)
  ;}
  else
  {
    if(leftValue2 < rightValue2)
    {
      ;analogWrite(leftmotor, 0)
      ;analogWrite(rightmotor, 225)
    ;}
    else
    {if(rightValue2 = leftValue2)
    {
      ;analogWrite(leftmotor, 225)
      ;analogWrite(rightmotor, 225)
    ;}
    }
  }
}
}
}
}
if(rightValue2 = leftValue2)

BZZZT!

thanks for sharing