Line Following Program ( HElP ME PLZZZZZ)

I have Made this line following program, i have 4 sensor, two centre for line following and the side two are to correct and back to the line.

This is the Program.

But it won't work ... i have tried alot.. Plzz Help me

i

nt right = 32;
int linefollowR = 30;
int linefollowL = 28;
int left = 26;
int leftmotor = 23;
int rightmotor = 24;
int R=0;
int LR=0;
int LL=0;
int L=0;

void setup()
{
  pinMode (right, INPUT);
  pinMode (linefollowR,INPUT );
  pinMode (linefollowL, INPUT);
  pinMode (left, INPUT);
  pinMode (leftmotor, OUTPUT);
  pinMode (rightmotor, OUTPUT);

  delay(4000);
}

void loop()
{ 

  if (R == HIGH && LR == LOW && LL == LOW && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, HIGH);
  }
  if (R == HIGH && LR == LOW && LL == HIGH && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, HIGH);

  }
  if (R == HIGH && LR == HIGH && LL == LOW && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, HIGH);
  }
  if (R == HIGH && LR == HIGH && LL == HIGH && L == LOW)
  {
  digitalWrite (leftmotor, LOW);
  digitalWrite (rightmotor, HIGH);
  }
  if (R == HIGH && LR == HIGH && LL == LOW && L == LOW)
  {
  digitalWrite (leftmotor, LOW);
  digitalWrite (rightmotor, HIGH);
  }
   if (R == HIGH && LR == LOW && LL == LOW && L == LOW)
  {
  digitalWrite (leftmotor, LOW);
  digitalWrite (rightmotor, HIGH);
  }

  if (R == LOW && LR == HIGH && LL == HIGH && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, LOW);
  }
  if (R == LOW && LR == LOW && LL == HIGH && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, LOW);
  }
   if (R == LOW && LR == LOW && LL == LOW && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, LOW);
  }
  
  else {
    digitalWrite(leftmotor, LOW);
    digitalWrite(rightmotor, LOW);
  }



}

Moderator: Code tags added.

if (R == HIGH && LR == LOW && LL == HIGH && L == HIGH)

You need to read R LR, LL and L, before you can test them

(and there’s probably no good reason for them to be globals either.)

But how can i read R, LR, LL, And L ?????

Well, you managed to write to "leftmotor" and "rightmotor". Have a look over at the reference section on the Main Site for some clues.

Here's another hint: http://arduino.cc/forum/index.php/topic,84249.msg631172.html#msg631172

Now i have change the program and read the value of R, LL, LR, And L But still only one motor work ,, while the second is off all the time

int right = 32;
int linefollowR = 30;
int linefollowL = 28;
int left = 26;
int leftmotor = 23;
int rightmotor = 24;
int R=0;
int LR=0;
int LL=0;
int L=0;

void setup()
{
  pinMode (right, INPUT);
  pinMode (linefollowR,INPUT );
  pinMode (linefollowL, INPUT);
  pinMode (left, INPUT);
  pinMode (leftmotor, OUTPUT);
  pinMode (rightmotor, OUTPUT);

  delay(4000);
}

void loop()
{ R = digitalRead(right);
  LR = digitalRead(linefollowR);
  LL = digitalRead(linefollowL);
  L = digitalRead(left);

  if (R == HIGH && LR == LOW && LL == LOW && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, HIGH);
  }
  if (R == HIGH && LR == LOW && LL == HIGH && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, HIGH);

  }
  if (R == HIGH && LR == HIGH && LL == LOW && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, HIGH);
  }
  if (R == HIGH && LR == HIGH && LL == HIGH && L == LOW)
  {
  digitalWrite (leftmotor, LOW);
  digitalWrite (rightmotor, HIGH);
  }
  if (R == HIGH && LR == HIGH && LL == LOW && L == LOW)
  {
  digitalWrite (leftmotor, LOW);
  digitalWrite (rightmotor, HIGH);
  }
   if (R == HIGH && LR == LOW && LL == LOW && L == LOW)
  {
  digitalWrite (leftmotor, LOW);
  digitalWrite (rightmotor, HIGH);
  }

  if (R == LOW && LR == HIGH && LL == HIGH && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, LOW);
  }
  if (R == LOW && LR == LOW && LL == HIGH && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, LOW);
  }
   if (R == LOW && LR == LOW && LL == LOW && L == HIGH)
  {
  digitalWrite (leftmotor, HIGH);
  digitalWrite (rightmotor, LOW);
  }
  
  else {
    digitalWrite(leftmotor, LOW);
    digitalWrite(rightmotor, LOW);
  }



}

Moderator edit: And again, code tags added.

Time to add some debug prints.

But still only one motor work , while the second is off all the time

We have a 50:50 chance of guessing which motor is working, and from that, we can infer which one isn’t working.
Or, you could tell us.

Your code would look a lot better if you nested some of those tests.

if(R == HIGH)
{
  if(LR == HIGH)
  {
  }
  else
  {
  }
}
else
{
}

Or even encode the four sensor values into a single “int”, and use a switch/case construct.
But whichever way, always with debug prints.