DC Motor Bot Arduino Library

DC Motor Bot is an Arduino library that allows you control bots created with 2 DC motors and H-Bridge IC like L293D.

Features

The library supports the following operations

  • Move Up
  • Move Down
  • Move Left
  • Move Right
  • Start
  • Stop

Examples

The library has an example sketch under the /examples folder which explains how to control the bot.

SimpleBot.ino – Shows the normal way of using the library

Dependency

This library does not require any other library to work.

Setup

Connect the DC motors to Arduino using H-Bridge IC like L293D.

TODO: Add more details and schematics.

Download

You can download the library from its github page. The examples are there inside the /examples folder. After downloading place the DCMotorBot folder inside your Arduino’s library folder.

License

The library and the example are released under released under BeerWare license.

I would, however, consider it a great courtesy if you could email me and tell me about your project and how this code was used, just for my own continued personal gratification

Stay updated

If you want to be informed when new version of this library is released, then subscribe to this blog’s RSS feed.

16 thoughts on “DC Motor Bot Arduino Library

    1. Sudar Post author

      It’s there in my TODO list for sometime now. But I am not getting enough free time πŸ˜‰

      Will do it as soon as I get some some free time.

      Reply
    1. Sudar Post author

      You should be able to use the library with Arduino Motor shield if you can configure the pins properly. I have not tried it though.

      Reply
  1. eliot ramos

    Unable to compile the examples. First i t says it needs the DCMotor library. When I add the library it says analog write is not defined.

    Reply
    1. Sudar Post author

      Which version of Arduino IDE are you using?

      Is the library and Arduino setup correctly? AnalogWrite is a built-in Arduino function.

      Also are you able to compile examples from other libraries?

      Reply
  2. Eliot Ramos

    I am using Arduino 1.6.7. I have downloaded other libraries without problems. Should I tell the IDE to include the compressed file or just the DCMotorBot.h part?
    Or should I change the name of the compressed folder from DCMotorBot – master to DCMotorBot?
    I built a differential motor platform with ir and ultrasound but the sketch is too repetitive for moving the bot fwd, back, left, right. Your library would be perfect if I can make it work. Don’t understand why the examples won’t compile.
    Thanks for replying.

    Reply
  3. Eliot Ramos

    These are the error I get with the DCMotorBot library:

    Arduino: 1.6.7 (Windows 10), Board: “Arduino/Genuino Uno”

    C:\Users\eramos\AppData\Local\Temp\Rar$DIa0.240\BasicBotSteering\BasicBotSteering.ino:16:17: fatal error: Bot.h: No such file or directory
    #include
    ^
    compilation terminated.
    exit status 1
    Error compiling.
    This report would have more information with “Show verbose output during compilation”
    enabled in File > Preferences.

    Arduino: 1.6.7 (Windows 10), Board: “Arduino/Genuino Uno”
    C:\Users\eramos\Documents\Arduino\libraries\DCMotorBot-master\DCMotorBot.cpp: In member function ‘void DCMotorBot::moveForward()’:
    C:\Users\eramos\Documents\Arduino\libraries\DCMotorBot-master\DCMotorBot.cpp:89:28: error: ‘analogwrite’ was not declared in this scope
    analogwrite(mE1, mSpeed);
    ^
    C:\Users\eramos\Documents\Arduino\libraries\DCMotorBot-master\DCMotorBot.cpp: In member function ‘void DCMotorBot::moveBackward()’:
    C:\Users\eramos\Documents\Arduino\libraries\DCMotorBot-master\DCMotorBot.cpp:104:28: error: ‘analogwrite’ was not declared in this scope
    analogwrite(mE1, mSpeed);
    ^
    exit status 1
    Error compiling.
    This report would have more information with “Show verbose output during compilation”
    enabled in File > Preferences.

    Reply
    1. Sudar Post author

      There was some typo in the library that was causing these errors.

      I have fixed both of them and have updated the code in github. Take the latest code from github and you should be able to compile without any issues.

      Let me know if you are still facing any issues.

      Reply
  4. Tux

    Hi,
    How to resolve analog write error.

    Open DCMotorBot.cpp and modify this file. There is a synthaxe error. It’s a W not w.

    void DCMotorBot::moveForward() {…
    analogWrite(mE1, mSpeed); to analogWrite(mE1, mSpeed);

    void DCMotorBot::moveBackward() {
    analogWrite(mE1, mSpeed);

    So, there is an error in BasicBotSteering.ino.
    Remplace #include to #include

    Best regards,

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *