Syntax error ?

This is the example Zoetrope out of the beginner book.

I am getting an error which states 'If' was not declared in this scope. I don't see the problem

The error message is pointing at the following line as the source of the error.

 if(onOffSwitchState == HIGH){
const int controlPin1=2;
const int controlPin2=3;
const int enablePin=9;
const int directionSwitchPin=4;
const int onOffSwithchStateSwitchPin=5;
const int potPin=A0;
int onOffSwitchState=0;
int previousOnOffSwitchState=0;
int directionSwitchState=0;
int previousDirectionSwitchState=0;
int motorEnabled=0;
int motorSpeed=0;
int motorDirection=1;

void setup(){
  pinMode(directionSwitchPin,INPUT);
  pinMode(onOffSwithchStateSwitchPin,INPUT);
  pinMode(controlPin1,OUTPUT);
  pinMode(controlPin2,OUTPUT);
  pinMode(enablePin,OUTPUT);
  digitalWrite(enablePin,LOW);
}

void loop(){
  onOffSwitchState=digitalRead(onOffSwithchStateSwitchPin);
  delay(1);
  directionSwitchState=digitalRead(directionSwitchPin);
  motorSpeed=analogRead(potPin)/4;
  if(onOffSwitchState != previousOnOffSwitchState){
    if(onOffSwitchState == HIGH){
      motorEnabled= !motorEnabled;
    }
  }
  if(directionSwitchState != previousDirectionSwitchState){
    If(directionSwitchState==HIGH){
      motorDirection != motorDirection;
    }
  }
  if(motorDirection==1){
    digitalWrite(controlPin1,HIGH);
    digitalWrite(controlPin2,LOW);
  }
  else{
    digitalWrite(controlPin1,LOW);
    digitalWrite(controlPin2,HIGH);
  }
  if(motorEnabled == 1){
    analogWrite(enablePin, motorSpeed);
  }
  else{
    analogWrite(enablePin, 0);
  }
  previousDirectionSwitchState=directionSwitchState;
  previousOnOffSwitchState=onOffSwitchState;
}

Case matters. You can't use a capital I in if. Its not there in the line you cut out, but I see it in at least one place in your code.

No, it would be pointing at this line:

If(directionSwitchState==HIGH){

The error message gives you the exact line number, and character position where the error is. No need to guess which line it's talking about....

Regards,
Ray L.