4 motors, 2 VNH5019 Motor Driver Shields, 1 Arduino


I currently have 2 motors driven by a Pololu Dual VNH5019 Motor Driver Shield for Arduino Uno. This works great! However, I now have bigger ambitions!

These questions are to avoid purchasing the wrong product(s)… otherwise I would just experiment :slight_smile:

Intended configuration/requirements:

  • Power 4 motors from 2 VNH5019 motor drivers from 1 Arduino Uno.
  • Both motor drivers will be powered from the same 12v lipo battery source.
  • The Arduino Uno has it’s own power source, so hot wiring from the motor driver is not required.
  • All four motors are Pololu 30:1 Metal Gearmotor 37Dx52L mm with 64 CPR Encoder (pololu.com/product/1443).
  • I need to be able to read from all four encoders.


  1. Is this possible? I don’t mind if the motor drivers are not configured/piggybacked as “shields” and soldered/connected separately to avoid conflicts with Arduino digital & analog ports.
  2. Will there be enough digital/analog/interupt ports remaining to read the encoders (4 pairs of white and yellow encoder outputs)? I have a new Arduino Due that I haven’t unwrapped yet, so happy to use that if the additional ports will solve the problem.
  3. If the answer so far is “NO”, then would multplexers work? playground.arduino.cc/Learning/4051 (sorry, trying to answer my own questions with newbie questions!)
  4. If the answer so far is “NO”, I guess I’ll just use two Arduino Unos and communicate between the two. Do you see any problems with this? (mainly timing?).
  5. If the answer is sill “NO”, I could use a quad motor driver, but didn’t find one on Pololu website - any recommendations for the above motors running on 12v?

Thanks for your assistance.


If you do not use the MxEN/Diag or MxCS pins, you can free up a total of 4 pins, which should allow you to use two of the VNH5019 shields and 4 encoders with an Arduino Uno. The Arduino Uno has 20 I/O pins, twelve of which would be used for the two VNH5019 shields when you do not use the MxEN/Diag and MxCS pins. Your four encoders would need an additional 8 pins.

If you need additional pins for other uses, the simplest option of those you mention would be to use the Arduino Due or an Arduino Mega. If you decide to use the Arduino Due, please see the “Note for Due users” about the current sense pins in the “What You Will Need” section of the “Pololu Dual VNH5019 Motor Driver Shield User’s Guide”.

You can use two of those shield either stacked on an Arduino or as stand-alone drivers. If you want to use them stacked as shields, you can use one shield normally and remap the other using the instructions in the “Remapping the Arduino Connections” section of the user’s guide.

Alternatively, you could use one as a shield, and connect the other as a stand-alone driver, connecting it with jumper wires to the pins indicated in the “Remapping the Arduino Connections” section of the user’s guide.


Brilliant! Thanks, that will solve the problem.

I would like to do the exact same thing using the Arduino Due. I have the first VNH5019 shield working fine. The second I am trying to remap the pins, however I saw on line 22 of DualVNH5019MotorShield.cpp [quote]"//PWM1 and PWM2 cannot be remapped because the library assumes PWM is on timer1"[/quote] . How can I change this to another timer?

Don’t use a timer.

Edit the DualVNH5019MotorShield.cpp file and remove all the following lines:

#if defined(AVR_ATmega168)|| defined(AVR_ATmega328P) || defined(AVR_ATmega32U4)

and just use the #else option and connect to PWM digital ports. Works great!

Thank you! How would I suggest I go about calling the different motors in the Arduino code? I was thinking of naming the second set of motors M3 and M4, then calling md.setM3Speed(400);. Then I was planning on making a copy of DualVNH5019MotorShield.cpp and renaming it to DualVNH5019MotorShield2.cpp and doing the same for the header file. Then in the copied files I would change all the “DualVNH5019MotorShield” to “DualVNH5019MotorShield2”, all the M1 to M3, all the M2 to M4, all the _PWM1 to _PWM3, all the _INA1 to _INA3, etc. Do you think this will work or am I making this more complicated than it needs to be?

What I did was pretty much just extend the existing DualVNH5019MotorShield.h & DualVNH5019MotorShield.cpp to add setM3Speed(…) & setM4Speed(…) etc as you mentioned. Simple… works great… but renamed it to MultiVNH5019MotorShield :slight_smile:

I changed the constructor to take the configuration info (PIN numbers) for each motor.

Note that PWM is 0 to 255 (not 400). You change the direction with the direction pins.

I am a new user to Arduino and motor drivers and it’s possible that my question is really obvious, but it has me a little stumped. I am also using two VNH5019 Driver Shields to run two 12v DC motors and a 12 v DC linear actuator. Both shields are stacked on top of an Arduino UNO. I am wiring the wings to open on a full sized stage prop of Chitty Chitty Bang Bang. The goal is to have an operator push a single momentary button and have the Arduino controll the opening of motorized concealed panels first then extend the wings via a linear actuator, and then push a different button to reverse the operation.

The problem I am having is that I can’t figure out when to put the switches into the stacked shield. I’ve seen examples where people have run closed contact switches between ground and pins D6 or D7 on the Arduino…but those pins are used with the motor shield. Can I attach the switch to D3 or D11 and have the information get down to the Arduino. Am I doing this the hard way?

Thanks in advance for any advice.


Those pins do connect to the Arduino. However, I cannot determine if those pins are free without knowing how you have remapped the connections on your second shield. What pins are you using to control or monitor the drivers on the additional shield?