'EN' was not declared in the scope

Hi everyone,
I am having a difficult time figuring why I keep getting this error message: ‘EN’ was not declared in the scope
I’ve attached screenshots of the sketch. Or if it helps I’ve also copy and pasted on this post.

Please help me find the issue.
thanks in advance

//Motor goes forward at given rate (from 0-255)
void forward (int rate)
{
digitalWrite(EN, LOW);
digitalWrite(MC1, HIGH);
digitalWrite(MC2, LOW);
analogWrite(EN, rate);
}

//Motor goes backward at given rate (from 0-255)
void reverse (int rate)
{
digitalWrite(EN, LOW);
digitalWrite(MC1, LOW);
digitalWrite(MC2, HIGH);
analogWrite(EN, rate);
}

//Stops motor
void brake ()
{
digitalWrite(EN, LOW);
digitalWrite(MC1, LOW);
digitalWrite(MC2, LOW);
digitalWrite(EN, HIGH);
}

void loop()
{
val = analogRead(POT);

//go forward
if (val > 562)
{
velocity = map(val, 563, 1023, 0, 255);
forward(velocity);
}

//go backward
else if (val < 462)
{
velocity = map(val, 461, 0, 0, 255);
reverse(velocity);
}

//brake
else
{
brake();
}
}

//Hbridge Motor Control
const int EN=9; //Half Bridge 1 Enable
const int MC1=3; //Motor Control 1
const int MC2=2; //Motor Control 2
const int POT=0; //POT on Analog Pin 0

int val = 0; //for storing the reading from the POT
int velocity = 0; //For storing the desired velocity (from 0-255)
void setup() {

pinMode(EN, OUTPUT);
pinMode(MC1, OUTPUT);
pinMode(MC2, OUTPUT);
brake(); //Initialize with motor stopped
}

void loop()
{
val = analogRead(POT);

//go forward
if (val > 562)
{

velocity = map(val, 563, 1023, 0, 255);
forward(velocity);
}

//go backward
else if (val < 462)
{
velocity = map(val, 461, 0, 0, 255);
reverse(velocity);
}

//brake
else
{
brake();
}
}

//Motor goes forward at given rate (from 0-255)
void forward (int rate)
{
digitalWrite(EN, LOW);
digitalWrite(MC1, HIGH);
digitalWrite(MC2, LOW);
analogWrite(EN, rate);
}

//Motor goes backward at given rate (from 0-255)
void reverse (int rate)
{
digitalWrite(EN, LOW);
digitalWrite(MC1, LOW);
digitalWrite(MC2, HIGH);
analogWrite(EN, rate);
}

//Stops motor
void brake ()
{
digitalWrite(EN, LOW);
digitalWrite(MC1, LOW);
digitalWrite(MC2, LOW);
digitalWrite(EN, HIGH);
}

Where in your code is EN defined?

You need to read the COMPLETE error listing because you have a lot more errors than just that one.

For a start the code you posted has 2 loop()s and several other duplicated functions. You need to sort those out first.

Steve

This is your sketch with enough changes to get it to compile.

const int EN = 9; //Half Bridge 1 Enable
const int MC1 = 3; //Motor Control 1
const int MC2 = 2; //Motor Control 2
const int POT = 0; //POT on Analog Pin 0


int val = 0;   //for storing the reading from the POT
int velocity = 0;   //For storing the desired velocity (from 0-255)




//Motor goes forward at given rate (from 0-255)
void forward (int rate)
{
  digitalWrite(EN, LOW);
  digitalWrite(MC1, HIGH);
  digitalWrite(MC2, LOW);
  analogWrite(EN, rate);
}




//Motor goes backward at given rate (from 0-255)
void reverse (int rate)
{
  digitalWrite(EN, LOW);
  digitalWrite(MC1, LOW);
  digitalWrite(MC2, HIGH);
  analogWrite(EN, rate);
}




//Stops motor
void brake ()
{
  digitalWrite(EN, LOW);
  digitalWrite(MC1, LOW);
  digitalWrite(MC2, LOW);
  digitalWrite(EN, HIGH);
}


void loop()
{
  val = analogRead(POT);


  //go forward
  if (val > 562)
  {
    velocity = map(val, 563, 1023, 0, 255);
    forward(velocity);
  }




  //go backward
  else if (val < 462)
  {
    velocity = map(val, 461, 0, 0, 255);
    reverse(velocity);
  }
  //brake
  else
  {
    brake();
  }
}




//Hbridge Motor Control
void setup()
{
  pinMode(EN, OUTPUT);
  pinMode(MC1, OUTPUT);
  pinMode(MC2, OUTPUT);
  brake(); //Initialize with motor stopped
}




void loop2()
{
  val = analogRead(POT);




  //go forward
  if (val > 562)
  {


    velocity = map(val, 563, 1023, 0, 255);
    forward(velocity);
  }




  //go backward
  else if (val < 462)
  {
    velocity = map(val, 461, 0, 0, 255);
    reverse(velocity);
  }




  //brake
  else
  {
    brake();
  }
}




//Motor goes forward at given rate (from 0-255)
void forward2(int rate)
{
  digitalWrite(EN, LOW);
  digitalWrite(MC1, HIGH);
  digitalWrite(MC2, LOW);
  analogWrite(EN, rate);
}




//Motor goes backward at given rate (from 0-255)
void reverse2(int rate)
{
  digitalWrite(EN, LOW);
  digitalWrite(MC1, LOW);
  digitalWrite(MC2, HIGH);
  analogWrite(EN, rate);
}




//Stops motor
void brake2()
{
  digitalWrite(EN, LOW);
  digitalWrite(MC1, LOW);
  digitalWrite(MC2, LOW);
  digitalWrite(EN, HIGH);
}

Great! That did compile. Now I have to figure out why the motor isn't turning on my breadboard. Thanks again