I have an existing code (working) that was designed to drive two dc motors with an arduino uno and an adafruit motor shield (with two L293D).
Now I changed to code to work with a pololu VNH5019 motor driver. The motors react to the commands (characters) sent by the transmitter. The problem is that motor 1 is always running at full speed, while motor 2 runs according to the case commands.
What I did was:
included the VNH5019 library (#include "DualVNH5019MotorShield.h")
DualVNH5019MotorShield md;
md.init();
changed the motor commands (md.setM1Speed()) in each case
Does anyone know why motor 1 is not running at variable speeds?
A wiring problem can be ruled in or out only by writing a simple sketch that sets the speed of one motor to several different speeds, with delay()s between each change. If one motor works, change the sketch to the other motor. If each works to control the speed and direction of one motor, the wiring is correct.
I solved this problem. I had a servo attached to pin9, which is used by the shield for the speed of motor 1. I just removed this line and now motor 1 works fine.
But now I'm facing another problem: Every now and then, the two motors get stuck at full speed (forward or reverse). When I turn off the transmitter, the motors keep running. Only powering down both the arduino and the vnh5019 stops them.
I already checked the incoming comands on the receiver side with the serial monitor. They seem to be OK.
It can't be a stack overflow, right?