oxmoon
November 16, 2021, 12:22am
1
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:
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?
oxmoon
November 16, 2021, 12:22am
2
Forgot to mention I have 2 of these motors: Pololu - 10:1 Micro Metal Gearmotor HPCB 6V
oxmoon:
DRV88333 Motor Driver
Please provide some wiring information and/or schematics of the board.
oxmoon:
powered by a 9V battery
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.
JCA34F
November 16, 2021, 1:47am
7
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;
See also FAQ - Arduino Forum for general rules on forum behaviour and etiquette.
Hello,
Welcome to the Arduino Forum.
This guide explains how to get the best out of this forum. Please read and follow the instructions below.
Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is fru…
Can you please post a picture of your project so we can see your component layout?
Thanks.. Tom..
1 Like
oxmoon
November 16, 2021, 3:07am
9
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?
oxmoon
November 16, 2021, 3:16am
10
Thank you! I formatted the code but unfortunately I am getting a "Discourse::InvalidAccess" error from trying to upload a jpeg.
oxmoon
November 16, 2021, 3:17am
11
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
oxmoon
November 16, 2021, 3:24am
13
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
oxmoon
November 16, 2021, 8:34pm
15
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);
}
oxmoon
November 16, 2021, 10:04pm
17
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
JCA34F
November 16, 2021, 10:16pm
18
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?
oxmoon
November 16, 2021, 10:46pm
20
No but they do work even though the connection is not reliable