Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Arduino to Micro Dual Serial Motor Controller?


I have the Pololu Micro Dual Serial Motor Controller and I have been trying to control it with a Arduino via serial.

I tried some code fond on another post
( Arduino + Pololu Micro Serial 8 Servo Controller )
but no such luck, below is my code any help is appreciated.

int motor_reset = 8;                // Motor reset pin

void setup()// run once, when the sketch starts 
   Serial.begin(9600);// set up Serial library at 9600 bps 

void put() 
   unsigned char buff[6]; 
  digitalWrite(motor_reset, LOW);   // reset motor controller
  digitalWrite(motor_reset, HIGH);
  delay(100);                         // reset delay

   buff[0]=0x80;//start byte 
   buff[1]=0x01;//Device type byte
   buff[2]=0x01;//Motor number and direction byte
   buff[3]=0x64;// Motor speed "0 to 128"  (100 is 64 in hex)
   delay(5000); // Wait 5 sec then resend data

   for(int i=0;i<4;i++){ 

void loop()// run over and over again 

When I open the Serial monitor in the Arduino IDE all I get back is ?[][]d
(Note: the [] is the box character)

Thanks for the help. :smiley:


Wow, Pololu+Arduino has become a popular combination lately. Anyway, you’re super-close, those four characters you’re seeing are the four bytes of your motor command misinterpreted as ASCII character codes, so you’ve got the serial output working. There are just a couple of minor problems with your code.

First, the Pololu serial motor controllers use device ID 0, and your code uses ID 1 (the device ID for the Pololu servo controllers). Just change the device-type line to:

buff[1]=0x00;//Device type byte

Second, resetting the motor controller at the beginning of your program is a good idea (to help it recover from the confusing serial data it sees when you download a program), but you need to set the reset pin to be an output by adding this line to your setup() function:

pinMode(motor_reset, OUTPUT);

Otherwise it’s still an input pin by default, and when you set it high, you’re really pulling it high with the AVR’s internal pull-up resistor, which is far too weak to bring the udsmc out of reset.

This last one isn’t a killer, but something to keep in mind for later. You have to hold the usdmc’s reset pin low for at least 2 microseconds to guarantee a reset. I’m not sure how much overhead the Arduino digitalWrite() command has, but with no delay between the commands to set the pin low and then high again it could be low for as little as 0.625 microseconds, one cycle of the Arduino’s 16MHz clock. It probably doesn’t matter in this case, sine the pin starts out low by default, but for good measure (like if you wanted to reset it again later in your code) I would throw a delay(1) command in between your two digitalWrite() commands.

Other than that your program sends out a properly formatted command to set motor 0 to half-forward speed. Sweet!

So, did that do it? And what are your plans for your two speed-controlled motors?



Hi Adam,

Big thanks on helping me with the code, funny thing is i knew the device ID needed to be 0x00 but I missed it, gerrrr… Good catch, thanks!

Oh ya the Arduino is getting popular, at the price and open source its a nice option to the BS2.

I’m building a lil bot with the code, Arduino and some parts from Pololu, I’m taking pics and documenting along the way will do nice write-up on it next week then publish it on some bot/tech sites, will give ref and thanks for you help… I’ll post a link here to the document when it’s up.


Need a hand with the dual serial controller and arduino

Hey guys I’m having a similar problem, hopefully you can help.

With the motor power disconnected, I just get 2 red lights, they stay on, but not motion…(cause there are no batteries this makes sense)

with the motor batteries hooked up, I get a quick flicker of two red lights, the motors hiccup… and then nothing.

I think the problem is the directions are confusing me, everything is in hex… when we go to the important bytes(config, or motor num, and direction) the explanation is in bits… but no example of the bits… the examples are back in hex, or decimal, not in bits…I’m even more confused as to why the bits are represented with zero on the right, or why the first motor is referred to as motor 1, instead of motor 0…

anyway here is my pin setup for the controller
1 positive terminal for 2 AA batteies(3v for motors)
2 ground
3 5v(same as ardunio power, or should this go to 9v/vcc?)
4 to pin 11 my serial tx pin
5 to pin 12, to reset controller
6 motor1 pos
7 motor1 gnd
8 motor2 gnd
9 motor2 pos

of course the battery pack goes to the same ground as everything else on the arduino, and I put a .1uf disk cap between the motor terminals as shown in the manual

[code]#include <SoftwareSerial.h>

byte motorRxPin = 10;//unused
byte motorTxPin = 11;
byte resetPin = 12;

unsigned char buff[4];

SoftwareSerial motorSerial = SoftwareSerial(motorRxPin, motorTxPin);

void setup() {
pinMode(motorTxPin, OUTPUT);
pinMode(motorRxPin, INPUT);
pinMode(resetPin, OUTPUT);

buff[0]=0x80;//start byte
buff[1]=0x02;//config command type byte
buff[2]=00000000;//Motor number and direction byte, I want this on motor 3 and 4, 2 motor mode, I don’t know how
for(int i=0;i<3;i++){

Serial.println(“sent config”);

digitalWrite(resetPin, LOW); // reset motor controller
digitalWrite(resetPin, HIGH);
Serial.println(“reset controller”);

void loop() {
buff[0]=0x80;//start byte
buff[1]=0x00;//Device type byte
buff[2]=0x00;//Motor number and direction byte, I want motor 3, forward
buff[3]=0x64;// Motor speed “0 to 128” (100 is 64 in hex)

//send data for motor0
for(int i=0;i<4;i++){
//send data for motor1
buff[1]=0x01; //Motor number and direction byte, I want motor 4, reverse
for(int i=0;i<4;i++) {
delay(5000); // Wait 5 sec then resend data

I know it must be the encoding, because I was able to get an L293D to work in like a half an hour, both directions 512 speeds in either direction… but with a lot of pins…


This subject continues here.