RoboClaw with Arduino and Pololu DC Motor

I’ve recently purchased a RoboClaw 2x5A motor controller to work with my Arduino UNO and Pololu 48CPR 75:1 geared DC motor (with Quadrature encoder), but I’m having so many problems with getting any code to compile (including examples from the RoboClaws’s own library) along with finding diagrams for wiring everything together. Can anyone help me please?


I’m sorry you are having trouble getting your RoboClaw and Arduino UNO working together. What version of the Arduino IDE are you using? Could you post the code you are trying to compile and the error messages you get when you try to compile it?

There is a wiring diagram for attaching motors with quadrature encoders on page 49 of the RoboClaw User Guide, which is linked to on the “Resources” tab of the 2x5A product page.


Hi Nathan, thanks for getting back to me.

So I’ve managed to fix the compiling error - the library for the RoboClaw that I had downloaded was wrong and I’ve managed to find a correction for it so the code now compiles fine. I’m using the latest Arduino programming environment (v1.6.3). I’ve wired the circuit as shown in the booklet, which is attached. So I have a 6V battery pack attached to the motor power, with a 48CPR Pololu DC Motor with Encoder attached to motor port 1. I am running the logic from the Arduino’s 5V power supply, with the ground of the Arduino connected to the ground of the RoboClaw. I have S1 and S2 on the RoboClaw attached to TX and RX on the Arduino for serial connection, with a separate 5V line powering the S1, S2 and S3 rails, which can be seen on the diagram. I have the encoder wired up as shown in the diagram too. I have used the example code from the RoboClaw’s library, which is also attached.

When I upload the program to the Arduino, nothing at all happens to the motor. Also, when I try and upload someone else’s example code into the Arduino (which they have shown working) I still get no response at all from the motor. The RoboClaw is set to mode 7 (Packet Serial Mode - 0x80), option 4 (38,400 baud rate for connection with the Arduino’s serial line) and I have also set the battery setting to option 1 (normal).

Any ideas what could be wrong?
PacketSerialEncoderSpeed.ino (2.22 KB)


It looks like the code you posted uses the Uno’s hardware serial port to talk to the computer and creates a software serial port to communicate with the RoboClaw. It seems like the baud rates in that example are pretty high. It might help to lower both baud rates to something less strenuous like 19,200bps or 9,600bps (and to change the settings on your RoboClaw to correspond) to see if that resolves the issue.

You might consider contacting Ion Motion Control (the RoboClaw’s manufacturer) directly to continue troubleshooting. They are more familiar with the various operating modes of the controllers and may be able to resolve your problem quicker.


Hi Nathan,

That has worked really well, the lower baud rate has actually made the example code work (with a few adjustments)!

Many thanks for your help :slight_smile:

I’m having a similar issue with the controlling a Pololu DC Motor w/ encoder (I’m using the 100:1 gearmotor). I’ve tried the code from Pololu’s Arduino library,and made the necessary changes to fix the compiling error.

For consistency, I used buzzer_453’s code (simply changing the baud rate), with the same wiring, mode/options, etc.

The only change is that I’m using a 9V battery pack (eventually I want to use an Arduino Mega, but I’m starting with an Uno for testing purposes).

I’m still having issues making the motor move. What other modifications are needed? I don’t have much experience with RoboClaw before this, so I might be missing something critical. I’d appreciate any help/advice that you might have!



Can you tell me what kind of 9V battery pack you are using?


Hello, I just also got the RoboCalw 2x15A and I am using the Arduino libraries but none of them work, Arduino can not even compile them.
In one of the Sketch that I am using named “PacketSerialEncoderSpeed” the error on the compile is as follow:

Arduino: 1.6.4 (Windows 7), Board: “Arduino Uno”

C:\Users\jjvillegas\Documents\Arduino\libraries\RoboClaw\RoboClaw.cpp: In member function ‘uint16_t RoboClaw::ReadError(uint8_t, bool*)’:
C:\Users\jjvillegas\Documents\Arduino\libraries\RoboClaw\RoboClaw.cpp:505:7: error: declaration of ‘bool valid’ shadows a parameter
bool valid;
C:\Users\jjvillegas\Documents\Arduino\libraries\RoboClaw\RoboClaw.cpp:506:48: error: ‘read2’ was not declared in this scope
uint16_t value = read2(address,GETERROR,&valid);
Error compiling.

By the way, I am using the Ion Motion software and I am able t orun the motor, read the encoder, etc. So the connections of my encoders are ok, The problem at the moment is with the Arduino Libraries. I hope you can test it and post one that works.

I hope you can help me.


I get the same compilation error when I try that sketch. We are contacting Ion Motion Control to see if they are aware of the problem and have a fix, but in the meantime, it looks like there’s a post about this on the Arduino forum that might be helpful.


I found the problem. The “read2” needs to be “Read2” in the ReadError function. i’ll have the corrected arduino library up on the site in a few minutes.


I was able to download and install that package, and the “PacketSerialEncoderSpeed” sketch compiles. (The updated library package is at the same URL as the old one.) Thanks for updating it.

Since it might not be obvious for everyone who reads this thread, I would like to add that acidtech is a representative from Ion Motion Control who also responds to questions about the RoboClaw on Ion Motion Control’s new forum.


Hi acidtech, I am a little confused as to the wiring… the OP said he was connecting the S1 and S2 on the RoboClaw to TX and RX on the arduino (which would be pins 1 & 0). The diagram backs this up. But the code makes it seem like the RoboClaw would be connected to pins 10 and 11.

//Definte terminal for display. Use hardware serial pins 0 and 1
BMSerial terminal(0,1);

//Setup communcaitions with roboclaw. Use pins 10 and 11 with 10ms timeout
RoboClaw roboclaw(10,11,10000);

(there are some typos in the comments)

Are the arduino pins 1 and 0 really connected to the RoboClaw S1 and S2 (respectively)? And what if anything is connected to pins 10 and 11?

Hello, jasonjaeger.

As I mentioned in my post on April 10th, it looks like that code uses the Uno’s hardware serial on pins 0 and 1 to communicate with a PC over the USB serial line and creates a software serial port on pins 10 and 11 to connect to the RoboClaw. You might try to post this question on Ion Motion Control’s support forum for a more definitive answer.