program will not compile. Need Help.

It is an obstacle avoidance program for the arduio bot.

#include <Servo.h>
#define irSensorPin 2 // IR sensor on this pin
#define irsensorPin 3 // IR sensor2 on this pin

//Main Variables needed in program
Servo leftservo; // Creates servo object for left side
Servo rightservo; // Creates Servo object for right side
int pos = 0; // variable to store the servo position
int avgFactor = 4; // amount of times you read the IR
int i; // counter for IR
int distRead = 0; // Var for the reading
int runningTotal = 0;// Total of readings
int distAvg = 0; // avg gdist readin
int distAvg2 = 0; // avg gdist readin

void setup()
{
Serial.begin(9600);
leftservo.attach(9); // attaches the servo on pin 9 to the servo object
rightservo.attach(10);
}

void IRREAD(){
i = 0; //counter
distAvg = 0;
runningTotal = 0;
for (i=0; i < avgFactor; i++) //sets up to read as many times as you want then average out readings
{
distRead = analogRead(irSensorPin 2);// Reads the value
runningTotal += distRead;// loads it into a tally
delay(50);// delay needed for nxt reading
}
distAvg = (runningTotal / avgFactor);// once reads are taken then avg them out
}
void IRREAD2()
{
i = 0; //counter
distAvg2 = 0;
runningTotal = 0;
for (i=0; i < avgFactor; i++) //sets up to read as many times as you want then average out readings
{
distRead = analogRead(irSensorPin 3); // Reads the value
running total += distRead;// loads it into a tally
delay(50);// delay needed for the next reading
}
disAvg2 = (runningTotal / avgFactor);// once reads are taken then avg them out
}

void loop()
{
Stop();
IRREAD();// calls the sensor
IRREAD2();// calls sensor2
Foward();//calls function for bot movement foward
Right();//calls function for bot movement 90deg right
Left();
Left45();
Right45();
Serial.println(distAvg); //display the results
Serial.print(" ");
Serial.println(distAvg2);//displays the results

if (distAvg < 214)
{
Foward();
)
else if ((distAvg > 214 && distAvg < 230)&&(distAvg2 > 190 && distAvg2 < 204))
{
Left();
}
else if((distAvg > 282 && distAvg < 298)&&(distAvg2 > 267 && distAvg2 < 283)){
Left();
}
else if((distAvg > 421 && distAvg < 436)&&(distAvg2 > 396 && distAvg2 < 416)){
Left();
}
else if((distAvg > 520 && distAvg < 600)&&(distAvg2 > 565 && distAvg2 < 595)){
Left();
}
else;

Please post the compiler's error message.

"In function 'void IRREAD()':
error: expected `)' before numeric constant In function 'void IRREAD2()':
In function 'void loop()':"

I think it doesn't like this:distRead = analogRead(irSensorPin 2);// line.
(then it isn't going to like some more lines)

#include <Servo.h>
#define irSensorPin 2 // IR sensor on this pin
#define irsensorPin 3 // IR sensor2 on this pin

The defines are repeat, i think that you have 2 ir sensors, so you may want to write irSensorPin1 and irSensorPin2 and then 2 and 3 for the different values.

analogRead(irSensorPin 2)

this is a syntax error - you have two tokens in the parameter list (i.e. between "(" and ")" ) but they are not separated by a comma, as function parameters should be. In addition, analogRead() only takes one parameter.

As a separate style issue, all caps are generally used for preprocessor directives (e.g. #define XYZ). A regular function should be mixed case (IRread, IrRead) or lowercase (irread).

-j