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.
When are you going to update with PWM? Great work by the way!!!
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.
thanks, works great
Glad to know that you like the library.
sir i have any possibilities arduino uno used to control large dc motor
Yes. You can use Arduino Uno to control a DC motor. But you may have to provide separate power supply to it.
thanks for ur reply
Could we use your library with the arduino motor shield or a tb6612fng? How should we configurate the pins dirleft, brakeleft, pwmleft, dirright, brakeright, pwmright… Thanks!!!!
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.
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.
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?
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.
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.
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.
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,
Both the issues are fixed now and I have updated code in github.