Motor Driver Problems

I have an Arduino UNO powered by usb, wired to the inputs of a DRV8833 Motor Driver and powered by a 9V battery.
Cannot for the life of me get the motors to work. When connected straight to the 9V or Arduino 5V + GND they work forward and reverse.

It is wired exactly like this:
0J3867.600

My code looks like:

#define B1IN 5
#define B2IN 3
#define A1IN 6
#define A2IN 9

void setup() {

  pinMode(B1IN, OUTPUT);
  pinMode(B2IN, OUTPUT);
  pinMode(A1IN, OUTPUT);
  pinMode(A2IN, OUTPUT);

  digitalWrite(B1IN, LOW);
  digitalWrite(B2IN, LOW);
  digitalWrite(A1IN, LOW);
  digitalWrite(A2IN, LOW);

}

void loop() {

  analogWrite(B1IN, 200);
  digitalWrite(B2IN, LOW);
  analogWrite(A1IN, 200);
  digitalWrite(A2IN, LOW);
  delay(2000);
  
  digitalWrite(B1IN, LOW);
  analogWrite(B2IN, 200);
  digitalWrite(A1IN, LOW);
  analogWrite(A2IN, 200);
  delay(2000);
}

I am completely new to Arduino so sorry for any missing information ahead of time.
Is it my code? Electronics? Both?

Forgot to mention I have 2 of these motors: Pololu - 10:1 Micro Metal Gearmotor HPCB 6V

Please provide some wiring information and/or schematics of the board.

The PP3 batteries are for smoke alarms, and are totally unsuitable for powering motors. You might get ONE motor to work for a few minutes, though, if connected directly to the battery.

You should never attempt to power a motor or servo from the 5V output of the Arduino.

Use a 4xAA battery pack instead, and connect the grounds.

Wouldn't it have been useful to mention the tutorial where you got your code?
https://electropeak.com/learn/interfacing-drv8833-dual-motor-driver-module-with-arduino/

I see they are using a different board than you are (or claim you are).

Yet another useless tutorial, by a typically misinformed contributor.

Does 1/5 second even give the motor enough time to move, even if it could? Try delay(2000) with one motor.

1 Like

Hi, @oxmoon
To add code please click this link;

Can you please post a picture of your project so we can see your component layout?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

1 Like

I will give it a try thank you! By connect the grounds do you mean from the arduino and the battery pack together or just like they are on the diagram? What is the difference between using the 9V and 4 1.5V AA?

Thank you! I formatted the code but unfortunately I am getting a "Discourse::InvalidAccess" error from trying to upload a jpeg.

Good catch! I actually had it at 2000 before but I was messing around with the code when I uploaded this and did not notice. Thank you!

The AA batteries can supply the startup current required by the motor, and will last up to 10 times longer.

1 Like

I appreciate the help! I will update the post once I get a battery pack tomorrow and test it out

The community is very helping. I got my answer too. Thanks

1 Like

Unfortunately it is still not working even with the 4 AA pack. The form isn't allowing me to upload pictures but it is wired exactly like the diagram in the post.

That should work, but you need to verify ALL connections for correctness and continuity. Post a clear, focused photo of your setup when you can.

I would not bother with analogWrite() for testing. Just do something like this (test ONE motor at a time):

void loop() {

  digitalWrite(B1IN, 1);
  digitalWrite(B2IN, 0);
  digitalWrite(A1IN, 0);
  digitalWrite(A2IN, 0);
  delay(2000);
  
  digitalWrite(B1IN, 0);
  digitalWrite(B2IN, 1);
  delay(2000);
}


I tested the motors using the wires connected to the power rail and they both work. Not sure what is causing the issue. I suspect the motor driver may be bad

Are the wires soldered to the motor terminals?

Not very useful without any information about the board. For example, why the decision to use Vin instead of VMM?

No but they do work even though the connection is not reliable