Underfined reference to error

Hello,

I am using the Seeed Studio Motor Shield V2 with the Uno. When I tried to upload the code to Arduino, I got the following error:

DCMotorDemo.cpp.o: In function loop': /Applications/DCMotorDemo.ino:18: undefined reference to motordriver’
/Applications/DCMotorDemo.ino:18: undefined reference to motordriver' /Applications/DCMotorDemo.ino:18: undefined reference to MotorDriver::goForward()’
/Applications/DCMotorDemo.ino:20: undefined reference to MotorDriver::stop()' /Applications/DCMotorDemo.ino:22: undefined reference to MotorDriver::goBackward()’
/Applications/DCMotorDemo.ino:24: undefined reference to MotorDriver::stop()' /Applications/DCMotorDemo.ino:26: undefined reference to MotorDriver::goLeft()’
/Applications/DCMotorDemo.ino:28: undefined reference to MotorDriver::stop()' /Applications/DCMotorDemo.ino:30: undefined reference to MotorDriver::goRight()’
/Applications/DCMotorDemo.ino:32: undefined reference to MotorDriver::stop()' DCMotorDemo.cpp.o: In function setup’:
/Applications/DCMotorDemo.ino:11: undefined reference to motordriver' /Applications/DCMotorDemo.ino:11: undefined reference to motordriver’
/Applications/DCMotorDemo.ino:11: undefined reference to MotorDriver::init()' /Applications/DCMotorDemo.ino:12: undefined reference to MotorDriver::setSpeed(signed char, unsigned char)’
/Applications/DCMotorDemo.ino:13: undefined reference to `MotorDriver::setSpeed(signed char, unsigned char)’

Do you know how to solve this issue? I am using a Mac. I store the file under Documents > From seeed studio > MotorDriver > examples > DCMotorDemo > DcMotorDemo.ino

Under the MotorDriver directory, there is a MotorDriver.cpp, MotorDriver.h and keywords.txt files. I downloaded the files from: http://www.seeedstudio.com/wiki/File:MotorDriver20121210.zip

When I tried to upload the code

"The" code has problems. If you need help fixing them, where the hell is "the" code?

C/C++ is NOT anything to do with Microsoft so it IS case sensitive!

Mark

PaulS:
"The" code has problems. If you need help fixing them, where the hell is "the" code?

Here is the code in DCMotorDemo.ino :

// Demo function:The application method to drive the DC motor.
// Author:Frankie.Chu
// Date:20 November, 2012

#include "MotorDriver.h"

void setup()
{
/Configure the motor A to control the wheel at the left side./
/Configure the motor B to control the wheel at the right side./
motordriver.init();
motordriver.setSpeed(200,MOTORB);
motordriver.setSpeed(200,MOTORA);
}

void loop()
{
motordriver.goForward();
delay(2000);
motordriver.stop();
delay(1000);
motordriver.goBackward();
delay(2000);
motordriver.stop();
delay(1000);
motordriver.goLeft();
delay(2000);
motordriver.stop();
delay(1000);
motordriver.goRight();
delay(2000);
motordriver.stop();
delay(1000);

}

I downloaded the files from
http://www.seeedstudio.com/wiki/File:MotorDriver20121210.zip

Hi, have you loaded the MotorDriver library into the Library folder of your IDE?

Tom.... :slight_smile:

Where is your declaration of "motordriver" Always post code in code tags - go back and read the examples on the site you got the code from again!

Mark

TomGeorge:
Hi, have you loaded the MotorDriver library into the Library folder of your IDE?

Tom.... :slight_smile:

Hi Tom, I am new to Arduino. I don't know what you meant by loading the MotorDriver library into the Library folder of my IDE.

I did the following:

  1. Downloaded the file from: http://www.seeedstudio.com/wiki/File:MotorDriver20121210.zip
  2. Double click it on the Mac desktop to unzip it. This created a folder called MotorDriver.
  3. In the Documents folder, created a folder called "From seded studio".
  4. Move the unzipped folder MotorDriver into the "From seeed studio" folder.
  5. In Arduino IDE, File->Open->Documents->"From seeed studio"->MotorDriver->examples->DCMotorDemo-> double clock DCMotorDemo.ino
  6. Clicked the right pointing arrow in the IDE to compile the file.

how to add 3rd party library

You haven't defined motordriver Yet you reference it many times.

KenF:
You haven't defined motordriver Yet you reference it many times.

It is in the MotorDriver.h file which is "included" at the beginning of DCMotorDemo.ino

How do I include this .h file in the DCMotorDemo.ino? I cannot open it as it is dimmed and can't be selected.

Have you followed the instructions in the link that Bijendra posted above? From what you described you've definitely not put the library folder in the correct place.

I have just followed the instructions in the link that Bijendra posted. Under Sketch->Import Library, I see MotorDriver under Contributed. Thank you very much.

What shall I do in order to run the demo, try to learn from it by making some changes and see how the motors turn? As the link which Bijendra provided mentioned, I did not unzipped the downloaded library. Could you please let me know the proper way?

I followed the same instructions, and got the same errors. I can't determine what the problem is. The code certainly looks like it should compile.

PaulS:
I followed the same instructions, and got the same errors. I can't determine what the problem is. The code certainly looks like it should compile.

So is it looking like an error in the library files?

OK Just downloaded MotorDriver20121210.zip.
Extracted into my sketch/libraries directory.
Opened the IDE (v1.0.6)
Clicked File.. Examples.. MotorDriver.. DCMotorDemo
Compiled fine.

Closed everything then opened IDE (V1.0.5 rev2)
Went through the same process
It compiles again.