POLULU MD03A proplems

I have a polulu MD03A motor driver that i want to use to drive two motors in one direction this is the code iam using but they go different directions what iam i doing wrong.

int InA1 = 7;
int InB1 = 8;
int PWM1 = 3;  //PWM1 connects to pin 3
int PWM2 = 6; //PWM2 coonects to pin 6
int InA2 = 13;
int InB2 = 12;
int PWM1_val = 127; //(25% = 64; 50% = 127; 75% = 191; 100% = 100)
int PWM2_val = 127;
void setup() {
  pinMode(InA1, OUTPUT);
  pinMode(InB1, OUTPUT);
  pinMode(PWM1, OUTPUT);
  pinMode(PWM2, OUTPUT);
  pinMode(InA2, OUTPUT);
  pinMode(InB2, OUTPUT);
void loop() {
    digitalWrite(InA1, HIGH);
    digitalWrite(InB1, LOW);
    analogWrite(PWM1, PWM1_val);
    analogWrite(PWM2, PWM2_val);
    digitalWrite(InA2, HIGH);
    digitalWrite(InB2, LOW);
    analogWrite(PWM1, PWM1_val);

Perhaps your doing nothing wrong, but you have your motors wired wrong! Remember that one motor will have to move in the opposite direction in to the other for your bot to move forwand.

What motor driver chip are you using? I know nothing of the Pololu MD03A, but haved used their DVR8833 this is a tiny module that works well. You could take a look here: www.melsaunders.co.uk under electronics and look at my bots, I have just ordered this too:https://www.banggood.com/DIY-Smart-Robot-Tank-Chassis-Tracking-Car-Kit-for-Arduino-SCM-p-1132211.html?rmmds=search that looks good…

Just give us more details a schematic would help or a drawing showing wiring, etc.

Hope it helps


Thank you for your quick response, here is a somewhat crude schematic of how i have done my wiring.


Your code and schematic look OK, having taken a quick look! But what I am trying to say that by doing it all right, you may have made a simple mistake! I take it you are using 2 DC motors, one each side of your robot/buggy? Switch it on and see which motor runs forward, assume that to be right. Do the motors have red & black leads? are the reds connected to the POS+ on the driver module? is that true for the other motor too? If so you need to swap over the wires on the reversing motor, as the motors are back to back, tho' the motors are both turning the same the 180 Deg turn makes it go backwards.

Or you could just swap the wires on in1A and in1B or in2x etc. or the motor leads on the module.

Also your PWM figures are a little out? 75%=192, 100%=255