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

Pin Remapping with MC33926 Library


Continuing the discussion from Arduino Motor Controller Pin #10 Remap?:

Thanks to AmandaS, I was able to make my MicroMaestro work with the USB 2.0 Host Shield. Now I want to add the MC33926 Dual Motor Shield into the mix. The USB shield uses pins d9-13, so I had to remap d9, d10, and d12 on the MC33926 shield.

First question, are pins d5 and d6 (timer0) the only option I have for remapping these pwm pins, since timer2 uses pin d11 and that is out too? Or can I map them to analog pins as well?

Second question, if I remap those pins, for example, to d5,6, would changing the library to work with timer0 be difficult? I have no idea how to begin such an undertaking. When it comes to programming, I am pretty much “a cut and paste what I find on the web” luddite. Any examples or references for doing this?

Third question, if I should avoid using the library, then all I have to do is use “pinMode” to define the motor channel, and “digitalWrite” to drive it high or low, as in this example?

For reference, below is the code I have working now, without the USB host shield attached. Bascially, I just want to be able to run this code with the d9, 10, and 12 pins from the dual motor shield remapped, e.g. d9 -> d5, d10 -> d6, d12->d3.

#include "DualMC33926MotorShield.h"
#include <SoftwareSerial.h>

DualMC33926MotorShield md;

const int buttonPinW = 2;     // the pin number of the pushbutton
int buttonStateW = 0;         // variable for reading the pushbutton status
boolean startW = true;   // use these to add a delay after pushing button

void setup() {
  // initialize the pushbutton pin as an input:
  pinMode(buttonPinW, INPUT);   

void loop(){
  // read the state of the pushbutton value:
  buttonStateW = digitalRead(buttonPinW);
  int speed =0;
  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonStateW == HIGH) { 
    if(startW == true){ 
    startW = false;
      Serial.println(" driving ");
      Serial.println(" White ON ");


Thanks for any help,


Hello, Mike.

You can use PWM pins on the Arduino with analogWrite() to send the PWM signal; one advantage to using a timer-based PWM signal is that you can use much higher frequencies. We generally recommend using frequencies near or above 20kHz when possible since that is above the typical audible range. As a reference, PWM signals generated with analogWrite() are usually at 490Hz or 980Hz, depending on the particular Arduino and pin. Details about this can be found on the analogWrite() reference page of Arduino’s website.

If you have no experience with configuring timers for PWM signals, there could be a bit of a learning curve. You would likely need to go through the controller’s datasheet and determine what registers you need to set to configure the signal how you want it. As far as resources for doing it, you could look at the source code for our MC33926 shield’s Arduino library to see how we configure timer1; however, please note that the values will be different for timer0, so you will probably need to reference the datasheet.

If you are not going to use a library (e.g. modify the library to work with your pin remap), you would need to control the direction and PWM of each motor channel. The direction is controlled with a high or low signal (e.g. digitalWrite()) on the M1DIR and M2DIR pins. The speed is controlled with the M1PWM and M2PWM pins, either through analogWrite() if you are using a PWM pin, or setting the appropriate register for the timer.


Changing mc33926 motor driver library to use Timer 2 instead of Timer 1
Dual MC33926 Shield for UNO with USB Host Shield

Thank you for the advice, Brandon. I do not really understand it yet, but I will start by looking over the source code for the library. If I manage to get a handle on it, I will try modifying the library and post that here for more advice.



While researching this, I found a few sources that said Timer0 is reserved by the Arduino environment for use in the delay() and millis() functions, so changing the Timer 0 prescaler messes those up along with any routines that depend on them.

If you are a competent programmer, I’m sure you can figure a way around this, but I am not. I was starting to get depressed, when I realized that I can remap pins d9 and d10 on the USB Host Shield, allowing me to use the mc33926 shield and library as is! Hooray!

Well, almost as is, since pin 12 still interferes with the SPI signals routed from the ICSP. But thats trivial. Sadly, cutting the traces on my dual mc33926 was meaningless.