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

HELP, Simple Motor running with DualVNH5019MotorShield and Uno3


Thanks Jon,
I have the same motor and fan running on a solar panel directly on another
coastline. It does run at lower voltages as the 20w solar panel only
generates under 10v when low sun etc.
I have it directly connected to the solar panel.
So I know that this motor can achieve what we need.

Ive just tested it too now on a 7vdc charger here and yes the fan runs slow and low revs. It seems to run at low volts fine

I have identical motor to which this shield with drive on vmh5019 at home to test.

Now, the last item I need is the right code to tell the motor to run at 50% or 200. then Im done and all works well.

Best regards


There are several things I want to cover. First, the green LED should be lit whenever the VNH5019 is driving a motor. Second, I was able to make a setup similar to yours with a VNH5019 shield, micro metal gearmotor, and an Arduino Mega running your code, which works. I used a wire to connect the A0 pin to a steady voltage to simulate your LDR. The green LED lights whenever the motor is spinning and adjusting the speed parameter of setM1Speed() changes how fast the gearmotor rotates.

Next, I thought about it some more and want to point out that controlling a computer fan with a motor driver like the VNH5019 is not likely to work because the computer fan is not designed to accept a pulse-width modulated supply voltage like what the VNH5019 outputs. (I answered your questions in part because you already had a setup and code that needed troubleshooting.)



Thanks Jon,

Sounds great, I have taken the computer fan off the test as was only using it in the early stages until the actual fan arrived that is the same as what I plan to use.

I have attached images of the actual fan the shield will drive and not sure if it will accept PWM but it is brushed and not like a computer fan, as it seems to run slower the less voltage is applied.

Is there some other C++ code I can use instead of md.setspeed ()???
Appreciate the help on this.


The functions in that library are written specifically to work with this motor driver and should behave as described in the documentation. If the library is not working for you, then something is wrong in your setup or with your hardware, and using some other code will not be a way to solve the issue. (We do not have any other libraries or example code available for that motor driver, anyway.)

Do you have a datasheet for the motor you actually plan to use? If you do not, can you provide a link to the product page for it?



Morning Jon,

The only link I can find for you is the Seaflow website but no datasheet.

Would one of these help on the output of the VNH5019?? I could cap it at 9v to fan?

If the pololu shield can’t control voltage then I can install and external one to do this, like a motor regulator control etc,
but would be nice to wrap this up in one neat package.

Can we not control motor voltage from the VNH5019??

I found this on Arduino.cc:
A call to analogWrite() is on a scale of 0 - 255, such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time) for example.
Is this something I need to add to my code?



I do not understand why you are asking about using a regulator. The motor you posted looks like it could be a brushed DC motor (though I didn’t see that specifically called out on the page), so the PWM outputs of the VNH5019 should be able to control its speed. Have you tried using it with the driver and the last thing of code you posted?

It seems like you are really new to motors and motor control. I recommend reading through this page on H-Bridge basics to help you understand how a brushed DC motor driver works.



Yes I’m new to motors.

The code all works well except for md.setspeed(), does not work to control
the motor speed.

If the shield can’t then I use external regulator.

Best regards



Well simple fix and thanks for you help, I didnt think to look at connections and I have the:

Positive into M1A
Negative into Ground from shield

Now have the:

Positive into M1A
Neg into M1B

Now the code fully works and speed control.

Thanks to everyone for the support.

Image is how I HAD it wired now into M1B, makes more sence


Is it worth me making a Github project for this???


I am glad you got your system working; thanks for letting us know what the issue was.

Using GitHub is a good way to organize changes to your code, so if you plan to continue making changes and want to be able to track them or revert to earlier versions, it might be useful to use it.



Thanks Jon was thinking of that too.

Just 1 small question, if I’m using the jumper on shield to power the uno
board can I still use the USB?

Cheers again for your help very appreciated.

Best regards


Yes, it is fine to connect your Arduino to your computer over USB while the ARDVIN=VOUT shorting block is in place.



Thanks again

Best regards