Error message I don't understand

I’ve been building over the past couple of months a line following robot based around an Arduino Uno and an Adafruit Motor Shield. I have built the hardware and have created a program designed to test if I have connected the motors up correctly. I will also use the program to find a time constant that I will use for a different program.

When I tried to verify the program in the IDE (version 1.0), it camed up with the following error message:

‘AF_DCMotor’ does not name a type

I don’t understand what it means, can someone please explain to me what it is trying to tell me?

Here’s the program:

#include <AFMotor.h>
AF_DCMotor left_motor (3, MOTOR12_8KHZ);
AF_DCMotor right_motor (4, MOTOR12_8KHZ);

void setup ()
{
  Serial.begin(9600);
  left_motor.setSpeed (200);
  right_motor.setSpeed (200);

}
void loop ()
{
  forward();
  backwards();
  STOP();
  delay(1000);
  
  backwards();
  forward();
  STOP();
  delay(1000);
  
  forward_left();
  backward_left();
  STOP();
  delay(1000);
  
  forward_right();
  backward_right();
  STOP();
  delay(1000);
  
  backward_right();
  forward_right();
  STOP();
  delay(1000);
  
  backward_left();
  forward_left();
  STOP();
  delay(1000);
}


void forward ()
{
  left_motor.run (FORWARD);
  right_motor.run (FORWARD);
}

void backwards ()
{
  left_motor.run (BACKWARD);
  right_motor.run (BACKWARD);
}

void forward_left ()
{
  left_motor.run (BACKWARD);
  right_motor.run (FORWARD);
}

void forward_right ()
{
  left_motor.run (FORWARD);
  right_motor.run (BACKWARD);
}

void backward_right ()
{
  left_motor.setSpeed (300);
  right_motor.setSpeed (100);
  
  left_motor.run (BACKWARD);
  right_motor.run (BACKWARD);
}

void backward_left ()
{
  left_motor.setSpeed (100);
  right_motor.setSpeed (300);
  
  left_motor.run (BACKWARD);
  right_motor.run (BACKWARD);
}

void STOP ()
{
  left_motor.run (RELEASE);
  right_motor.run (RELEASE);
}

Moderator edit: And there’s the sketch with CODE TAGS

I don't understand what it means, can someone please explain to me what it is trying to tell me?

It means exactly what it says. The string "AF_DCMotor" is not the name of a type of variable. You are trying to create an instance of a variable of that type, but that type is not defined.

Now, I'll bet that that particular error message was not the only error message that was printed. There was almost certainly one that said that the compiler was unable to find AFMotor.h. Why are you ignoring that particular message?

Errors almost always need to be fixed in the order listed.

I've copied the Adafruit Motor shield library to the libraries folder to see if that rectifies the problem; it didn't. When I attempted to verify the program in the IDE, it came up with the following message:

Error compiling.

Did I sort out one problem and create another, or did I simply create another problem?

When I attempted to verify the program in the IDE, it came up with the following message:

Copy and paste the exact message, and all of them.

I've copied the Adafruit Motor shield library to the libraries folder

Which libraries folder? I have three of them.

Did you restart the IDE after installing the library?

Here's the exact message:

H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:7:22: error: WProgram.h: No such file or directory
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp: In member function 'void AFMotorController::enable()':
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:29: error: 'OUTPUT' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:29: error: 'pinMode' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:39: error: 'LOW' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:39: error: 'digitalWrite' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp: In member function 'void AFMotorController::latch_tx()':
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:47: error: 'LOW' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:47: error: 'digitalWrite' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:58: error: 'HIGH' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:64: error: 'HIGH' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:67: error: 'HIGH' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp: In function 'void initPWM1(uint8_t)':
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:94: error: 'OUTPUT' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:94: error: 'pinMode' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp: In function 'void initPWM2(uint8_t)':
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:132: error: 'OUTPUT' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:132: error: 'pinMode' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp: In function 'void initPWM3(uint8_t)':
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:170: error: 'OUTPUT' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:170: error: 'pinMode' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp: In function 'void initPWM4(uint8_t)':
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:210: error: 'OUTPUT' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:210: error: 'pinMode' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp: In constructor 'AF_Stepper::AF_Stepper(uint16_t, uint8_t)':
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:323: error: 'OUTPUT' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:323: error: 'pinMode' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:325: error: 'HIGH' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:325: error: 'digitalWrite' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:340: error: 'OUTPUT' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:340: error: 'pinMode' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:342: error: 'HIGH' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:342: error: 'digitalWrite' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp: In member function 'void AF_Stepper::step(uint16_t, uint8_t, uint8_t)':
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:388: error: 'delay' was not declared in this scope
H:\arduino-1.0\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp:398: error: 'delay' was not declared in this scope

The library that I copied is called Adafruit_Motor_Shield_library and I did restart the IDE.

When I tried to verify the program in the IDE (version 1.0),

error: WProgram.h: No such file or directory

Bingo!

Are you suggesting that that particular file is missing from the library I downloaded? If so, how do I obtain the file? If not, do I simply need to download an updated version of the library?

Open the file AFMotor.cpp and change
#include <WProgram.h>
to
#include <Arduino.h>

But now when I try to verify the program, it says that:

'AF_DCMotor' does not name a type

Here's the complete error message:

sketch_nov25a:1: error: 'AF_DCMotor' does not name a type
sketch_nov25a:2: error: 'AF_DCMotor' does not name a type
sketch_nov25a.cpp: In function 'void setup()':
sketch_nov25a:7: error: 'left_motor' was not declared in this scope
sketch_nov25a:8: error: 'right_motor' was not declared in this scope
sketch_nov25a.cpp: In function 'void forward()':
sketch_nov25a:47: error: 'left_motor' was not declared in this scope
sketch_nov25a:47: error: 'FORWARD' was not declared in this scope
sketch_nov25a:48: error: 'right_motor' was not declared in this scope
sketch_nov25a.cpp: In function 'void backwards()':
sketch_nov25a:53: error: 'left_motor' was not declared in this scope
sketch_nov25a:53: error: 'BACKWARD' was not declared in this scope
sketch_nov25a:54: error: 'right_motor' was not declared in this scope
sketch_nov25a.cpp: In function 'void forward_left()':
sketch_nov25a:59: error: 'left_motor' was not declared in this scope
sketch_nov25a:59: error: 'BACKWARD' was not declared in this scope
sketch_nov25a:60: error: 'right_motor' was not declared in this scope
sketch_nov25a:60: error: 'FORWARD' was not declared in this scope
sketch_nov25a.cpp: In function 'void forward_right()':
sketch_nov25a:65: error: 'left_motor' was not declared in this scope
sketch_nov25a:65: error: 'FORWARD' was not declared in this scope
sketch_nov25a:66: error: 'right_motor' was not declared in this scope
sketch_nov25a:66: error: 'BACKWARD' was not declared in this scope
sketch_nov25a.cpp: In function 'void backward_right()':
sketch_nov25a:71: error: 'left_motor' was not declared in this scope
sketch_nov25a:72: error: 'right_motor' was not declared in this scope
sketch_nov25a:74: error: 'BACKWARD' was not declared in this scope
sketch_nov25a.cpp: In function 'void backward_left()':
sketch_nov25a:80: error: 'left_motor' was not declared in this scope
sketch_nov25a:81: error: 'right_motor' was not declared in this scope
sketch_nov25a:83: error: 'BACKWARD' was not declared in this scope
sketch_nov25a.cpp: In function 'void STOP()':
sketch_nov25a:89: error: 'left_motor' was not declared in this scope
sketch_nov25a:89: error: 'RELEASE' was not declared in this scope
sketch_nov25a:90: error: 'right_motor' was not declared in this scope

I have a feeling that I will probably need to change the line AF_DCMotor into something else. Any idea what I have to do to make it valid once again? I'm not particularly familiar with this language; I only started learning it a couple of months ago.

That define/declaration/typredef should be in AFMotor.h. Can you post the contents of that include file?

I have a feeling that I will probably need to change the line AF_DCMotor into something else.

No.

What does your code look like? I opened the MotorTest example in the library, and got the error about WProgram.h. I edited the AFMotor.cpp file, and changed WProgram to Arduino, and the sketch compiled.

So, unless you are not showing all the error messages, you are not compiling an example sketch (or not the same one I did) or you have mangled something in AFMotor.cpp.

Post your sketch and the modified copy of AFMotor.

By the way, user-downloaded libraries, like AFMotor, do NOT go in the Arduino-1.0 libraries folder.

I created my own motor test program as a way of improving my programming skills and have posted the code earlier in this topic. If the solution is to edit the files, can you show me and explain to me how to edit it because last time I edited notebook files that contained data like this, I screwed up a video game I owned.

// If this does not generate a "file not found" error when you compile your sketch
#include <AFMotor.h>
// ...then this data type define or typedef (or something close maybe?) is there.
AF_DCMotor left_motor (3, MOTOR12_8KHZ);

You posted the code, not the contents of AFMotor.h.

Open AFMotor.h and see if those data types (AF_DCMotor, FORWARD, BACKWARD) are defined or there are typedefs there.

edit: left_motor and right_motor are declared there using data type AF_DCMotor. I changed that.

I posted your code into a new sketch. I compiled. I got this “set of errors”:

Binary sketch size: 3406 bytes (of a 30720 byte maximum)

This was after changing DFMotor.cpp to look like this (only showing the first few lines to preserve space):

// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!


#include <avr/io.h>
#include "Arduino.h"
#include "AFMotor.h"

static uint8_t latch_state;

#if (MICROSTEPS == 8)
uint8_t microstepcurve[] = {0, 50, 98, 142, 180, 212, 236, 250, 255};
#elif (MICROSTEPS == 16)
uint8_t microstepcurve[] = {0, 25, 50, 74, 98, 120, 141, 162, 180, 197, 212, 225, 236, 244, 250, 253, 255};
#endif

The only change was on the 7th line, to change WProgram to Arduino.

That appears to have sorted out my problem; the IDE now compiles the program. Thank you all for your help! :smiley:

Hi all,
I'm begining with Arduino, so currently making a 2WD autonomous bot, based on the "Make an Arduino-controlled Robot" book by Michael Margolis.
I wanted to check if i connected the motors correctly, so launched the "MotorTest2wd.ino"
But i have same type of error message that the previous user "Grim_Jellynton" ... And i don't know how fix it : it's the first time i had to refer to a library...

So i paste you my error message, if someone could help me to fix it :

C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:7:22: error: WProgram.h: No such file or directory
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In member function 'void AFMotorController::enable()':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:27: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:27: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:37: error: 'LOW' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:37: error: 'digitalWrite' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In member function 'void AFMotorController::latch_tx()':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:45: error: 'LOW' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:45: error: 'digitalWrite' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:56: error: 'HIGH' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:62: error: 'HIGH' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:65: error: 'HIGH' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In function 'void initPWM1(uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:90: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:90: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In function 'void initPWM2(uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:123: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:123: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In function 'void initPWM3(uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:157: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:157: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In function 'void initPWM4(uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:193: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:193: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In constructor 'AF_Stepper::AF_Stepper(uint16_t, uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:303: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:303: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:305: error: 'HIGH' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:305: error: 'digitalWrite' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:322: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:322: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:324: error: 'HIGH' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:324: error: 'digitalWrite' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In member function 'void AF_Stepper::step(uint16_t, uint8_t, uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:374: error: 'delay' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:386: error: 'delay' was not declared in this scope

ty all !

and when i replace "Wprogram.h" by "Arduino.h" as previously suggested, it's quite the same :

C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:7:22: error: WProgram.h: No such file or directory
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In member function 'void AFMotorController::enable()':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:27: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:27: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:37: error: 'LOW' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:37: error: 'digitalWrite' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In member function 'void AFMotorController::latch_tx()':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:45: error: 'LOW' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:45: error: 'digitalWrite' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:56: error: 'HIGH' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:62: error: 'HIGH' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:65: error: 'HIGH' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In function 'void initPWM1(uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:90: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:90: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In function 'void initPWM2(uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:123: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:123: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In function 'void initPWM3(uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:157: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:157: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In function 'void initPWM4(uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:193: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:193: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In constructor 'AF_Stepper::AF_Stepper(uint16_t, uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:303: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:303: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:305: error: 'HIGH' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:305: error: 'digitalWrite' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:322: error: 'OUTPUT' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:322: error: 'pinMode' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:324: error: 'HIGH' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:324: error: 'digitalWrite' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp: In member function 'void AF_Stepper::step(uint16_t, uint8_t, uint8_t)':
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:374: error: 'delay' was not declared in this scope
C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:386: error: 'delay' was not declared in this scope

and when i replace "Wprogram.h" by "Arduino.h" as previously suggested, it's quite the same :

Well, clearly, you didn't replace WProgram.h with Arduino.h in (all) the right place(s). Which file(s) did you edit?

I replaced “Wprogram.h” only in the AFMotor.cpp file, in my libraries.
Here is its location :
“C:\Users\JerM\Documents\Arduino\libraries\AFMotor\AFMotor.cpp”

the original :

// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!
// added Leonardo support - Michael Margolis, 24 July 2012 
#include <avr/io.h>
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "AFMotor.h"
static uint8_t latch_state;
#if (MICROSTEPS == 8)
uint8_t microstepcurve[] = {0, 50, 98, 142, 180, 212, 236, 250, 255};
#elif (MICROSTEPS == 16)
uint8_t microstepcurve[] = {0, 25, 50, 74, 98, 120, 141, 162, 180, 197, 212, 225, 236, 244, 250, 253, 255};
#endif
AFMotorController::AFMotorController(void) {
}...

and then :

// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!
// added Leonardo support - Michael Margolis, 24 July 2012 
#include <avr/io.h>
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "Arduino.h"
#endif
#include "AFMotor.h"
static uint8_t latch_state;
#if (MICROSTEPS == 8)
uint8_t microstepcurve[] = {0, 50, 98, 142, 180, 212, 236, 250, 255};
#elif (MICROSTEPS == 16)
uint8_t microstepcurve[] = {0, 25, 50, 74, 98, 120, 141, 162, 180, 197, 212, 225, 236, 244, 250, 253, 255};
#endif
AFMotorController::AFMotorController(void) {
} ...

I replaced "Wprogram.h" only in the AFMotor.cpp file, in my libraries.

That wasn't necessary. What version of the IDE are you using?