-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); 
}

1 Answer 1

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.