Hi,
I have a Uno R4 and a Motor Shield Rev3. I am trying to use the pwm.h library and use the pwmOut object to set both motor outputs to be 16khz (period set to 62us).
If I use either motor A (Pin D3) or motor B (Pin D11) then everything works as expected, but the moment I initialise both motors nothing works anymore.
I am initialising using:
#include "pwm.h"
PwmOut motorA(D3);
PwmOut motorB(D11);
then in setup() I am setting:
motorA.begin(62.0, 0.0);
motorB.begin(62.0, 0.0);
When used individually it all works, but initialise them both and it stops (neither motor responds). If I move motorB from pin 11 to pin 5 then it works again and both motors respond, so it is something to do with trying to use pin 3 and 11 at the same time.
I can't easily move from pin 11 to 5 because the rev3 motor shield is hard wired to use 3 and 11.
I think it is something to do with pins 3 and 11 sharing a clock, but I was hoping that wouldn't be an issue as I am running both motors at the same frequency.
Any advice on getting this working with ping 3 and 11 would be most appreciated.
Thanks!
6 posts - 2 participants