expected primary-expression before ';' token

Could someone please help me with this?

#include <Servo.h>

Servo servoR;
Servo servoL;
int pos = 0;
int Max_Dist=185; // Maximum distance to check against.
int Best_Dist=400; // Best distance to check against.
int sensorPin_Right = 1; // select the Arduino input pin for the IR PT pin a1
int sensorPin_Left = 0; // select the Arduino input pin for the IR PT pin a0
int sensorValue_right = 0; // variable to store the value coming from the ir phototransistor(Right)
int sensorValue_left = 0; // variable to store the value coming from the ir phototransistor(left)

void setup()
{
servoL.attach(2); // attaches the servo on pin 2 to the servo object ect
servoR.attach(3);

}

void loop()
{
sensorValue_right = analogRead(sensorPin_Right);//read the value from the sensor and determine if the object is in range if not return 0
sensorValue_left = analogRead(sensorPin_Left);

if (sensorValue_left < sensorValue_right){
for(pos = 0; pos < ; pos += 1) // goes from 0 degrees to 0 degrees
{ // in steps of 1 degree
servoR.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 45; pos>=1; pos-=1) // goes from 45 degrees to 0 degrees
{
servoR.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}

if else (sensorValue_left > sensorValue_right){
for(pos = 0; pos < ; pos += 1) // goes from 0 degrees to 0 degrees
{ // in steps of 1 degree
servoL.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 45; pos>=1; pos-=1) // goes from 45 degrees to 0 degrees
{
servoL.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
}

for(pos = 0; pos < ; pos += 1)  // goes from 0 degrees to 0 degrees

Pos is less then what?

Also it’s else if, not if else

Try this. Not sure it does what you want, but it does compile without errors:

#include <Servo.h>

Servo servoR; 
Servo servoL;
int pos = 0;   
int Max_Dist=185; // Maximum distance to check against.
int Best_Dist=400; // Best distance to check against.
int sensorPin_Right = 1; // select the Arduino input pin for the IR PT pin a1
int sensorPin_Left = 0; // select the Arduino input pin for the  IR PT pin a0
int sensorValue_right = 0; // variable to store the value coming from the ir phototransistor(Right)
int sensorValue_left = 0; // variable to store the value coming from the ir phototransistor(left)

void setup()
{
servoL.attach(2);  // attaches the servo on pin 2 to the servo object ect
servoR.attach(3);

}

void loop()
{
   sensorValue_right = analogRead(sensorPin_Right);//read the value from the sensor and determine if the object is in range if not return 0
   sensorValue_left = analogRead(sensorPin_Left);

   if (sensorValue_left < sensorValue_right)
    {
     for(pos = 0; pos < 45; pos += 1)  // goes from 0 degrees to 45 degrees
      {                                  // in steps of 1 degree
        servoR.write(pos);              // tell servo to go to position in variable ‘pos’
        delay(15);                       // waits 15ms for the servo to reach the position
      }
     for(pos = 45; pos>=1; pos-=1)     // goes from 45 degrees to 0 degrees
      {
       servoR.write(pos);              // tell servo to go to position in variable ‘pos’
       delay(15);                       // waits 15ms for the servo to reach the position
      }
    }

   else if (sensorValue_left > sensorValue_right)
    {
      for(pos = 0; pos < 45; pos += 1)  // goes from 0 degrees to 0 degrees
       {                                  // in steps of 1 degree
         servoL.write(pos);              // tell servo to go to position in variable ‘pos’
         delay(15);                       // waits 15ms for the servo to reach the position
       }
      for(pos = 45; pos>=1; pos-=1)     // goes from 45 degrees to 0 degrees
       {
         servoL.write(pos);              // tell servo to go to position in variable ‘pos’
         delay(15);                       // waits 15ms for the servo to reach the position
       }
    }
 }

Lefty

Also - I think there was a missing end bracket "}"...

As retrolefty has shown, Gearhead14, with his "cleaned up" version of the code - syntax and -especially- indentation of the code blocks matter in finding some of these errors. Format your code, and it'll help to allow you to spot some of these bugs...

Thanks for your help. I'll try the code as soon as I get the chance. What I'm trying to do basically is when the left ir phototransisistor value is higher than the right the left servo is supposed to move back and forth and basically the same for the other way around.