-2

I connected the 12v power supply with 9v battery. The problem is that when i run 1 motor at time from any side (out 1, 2 out 3, 4) it works perfectly, but when I try to run both of them, only one will run and the other won't. They work if I run one motor at a time.

Is this a problem with not enough power? The motors are DC gear motors. This is the code:

int in1 = 12;
int in2 = 13;
int in3 = 8;
int in4 = 9;
int en1 = 11;
int en2 = 10;
void setup() {
 pinMode(in3, OUTPUT);
 pinMode(in4, OUTPUT); 
 pinMode(en1, OUTPUT);
 pinMode(in1, OUTPUT);
 pinMode(in2, OUTPUT); 
 pinMode(en2, OUTPUT);
}
void loop() {
 analogWrite(en1, 255);
 digitalWrite(in1, LOW);
 digitalWrite(in2, HIGH);
 analogWrite(en2, 255);
 digitalWrite(in3, LOW);
 digitalWrite(in4, HIGH); 
}
dda
1,5951 gold badge12 silver badges17 bronze badges
asked Nov 28, 2023 at 13:58

2 Answers 2

0

Yes, most likely. Motors can draw a lot of power and your 9v battery is probably struggling to output enough voltage. 50-100 mA is about the max current you want to draw from a 9v. 9v batteries have a high internal resistance and the voltage will drop potentially well below 9v when you draw a lot of current from them. Used to make Altoids tin USB chargers back in the day with a 9v but cellphones now need multiple Amps of power and so do motors.

Here's a couple things you can do to check:

Set up your code to run both motors. Connect a motor to one side and see if it works. Then connect it to the other side (without changing the program or other wiring.) If that motor runs on both sides, check the other motor. This will make sure both motors are good and that both channels on the driver are good. Check the voltage on the battery and the motor and write down the values each time. If the current you measure with a single motor is much higher than 25-50 mA, 2 motors will exceed the limit. Note the motor (label them) and the channel it is connected to.

If that seems to check out, connect both motors. We know they don't both spin, but take this time and measure battery voltage and motor voltage. Measure the current if possible too. If you are getting greater than 50-100mA from the battery, you are likely going to have issues.

answered Nov 28, 2023 at 15:20
0

In the code, you have set the enable pins (en1 and en2) for both motors to the maximum value (255), which means they will run at full speed. If one of the motors cannot start under high load, you can try reducing the PWM value, for example, setting it to 200 or lower, to see if it is possible to start both motors simultaneously.

answered Nov 15, 2024 at 3:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.