import this library into a program

15 Jan 2012

Hallo.

I can not:import this library into a program (HBridgeMotor.h) I do the next steps: 1 Start the compiler. 2 New. 3 name:HBridgeL293. 4 Click on : main.ccp 5.Past: HBridgeMotor.ccp in this window 6 compile (can not open HBRidgeMotor.h go to Code and click on: import this code into a program. 7 in the compiler screen: select path and select":HBridgeL293. 8 now in the screen: Library: HBridgeMotor. see the documentation for this library (new window)

How further?? Hope any one can give me advice. Thanks, Jackpo.

15 Jan 2012

Hi Jack,

I think you are probably trying to use the HBridgeMotor library http://mbed.org/users/harryeakins/libraries/HBridgeMotor/lxt2ln within another program?

If so:

  1. Create the new program you want to use it within using "New" e.g. program name "HBridgeL293"
  2. Go to http://mbed.org/users/harryeakins/libraries/HBridgeMotor/lxt2ln and select "Import this library into a program"
  3. When it loads the compiler, keep "HBridgeMotor" as the name, and choose "HBridgeL293" as the import destination

And you should be done!

To use the library, you'll want to #include it within your main program. e.g.

#include "mbed.h"
#include "HBridgeMotor.h"

int main() {
}

Also, take a look at https://mbed.org/cookbook/Motor for some other H-bridge information.

Hope that helps,

Simon

15 Jan 2012

Hallo Simon,

Thanks for reply. But i do so then in the mainscreen the message: Library: HBridgeMotor See the documentation for this library (new window)

What are i doing wrong? Jackpo.

15 Jan 2012

You've done nothing wrong the library is in your project at that stage, if you look at the project tree on the left it should be there, use it as simon said

16 Jan 2012

By compiling the next errors are there: /media/uploads/Jackpo/hbridgemotor.jpg

Jackpo

16 Jan 2012

When you import the library the source for the library is automatically included into your project, you don't need to copy it into your main.cpp, you are getting the error as there is now 2 versions of the same class with the same name so there is name conflicts along with other issues,

main.cpp

#include "mbed.h"
#include "HBridgeMotor.h"

HBridgeMotor motorController(p23, p24); //Initialise the HBridge with Pin 23 as forward PWM 
                                        //and pin 24 as reverse PWM
float speed = 1.0f;

int main() {
  motorController.set(speed); //set speed to full power forward, -1.0f would be full power reverse
  while(true){
     //wait here forever
  } 
}
16 Jan 2012

OK. Thanks ferry much. Jackpo