Code not working with l9110 H-bridge

Hello! I'm fairly new to the Arduino world but I stupidly decided to use it for a school project, which's deadline is very close. I'm using a Arduino Uno and a l9110 h-bridge to move two motors. The problem I'm having is that the code never seems to reach the end, randomly stopping at different intervals. Sometimes the first motor will not spin at all, sometimes it reached the stage where motor B goes to spin for the second time. The fact that it is stopping in random places is making me believe it is a wiring problem but I would love for someone to take a look at my code

const int A1A = 8;
const int A1B = 9;
const int B1A = 10;
const int B1B = 11;

void setup(){

pinMode(A1A, OUTPUT);
pinMode(A1B, OUTPUT);
pinMode(B1A, OUTPUT);
pinMode(B1B, OUTPUT);
}

void loop(){
  
  digitalWrite(A1A, HIGH);  //STAIRS COME BACK
  digitalWrite(A1B, LOW);
  delay(2600);
  digitalWrite(A1A, 0);
  digitalWrite(A1B, 0);
  
  delay(1000);
  
  digitalWrite(B1A, HIGH);  //LIFT GOES UP
  digitalWrite(B1B, LOW);
  delay(10000);
  
  digitalWrite(B1A, 0);
  digitalWrite(B1B, 0);
  delay(5000);

  digitalWrite(B1A, LOW);   //LIFT GOES DOWN
  digitalWrite(B1B, HIGH);
  delay(10000);
  digitalWrite(B1A, 0);
  digitalWrite(B1B, 0);
  
  delay(1000);
  
  digitalWrite(A1A, LOW);   //STAIRS GO FORWARD
  digitalWrite(A1B, HIGH);
  delay(2600);
  
}

At the end of loop(), motor A is going one direction and when loop() restarts the motor is slammed the other way. That motor will draw a lot of current when that happens.

Please post a schematic.

What is the motor power supply? Supply voltage? Supply current capacity?

Hi thanks for the supply what's the best way to make a schematic? I'm using a elego power supply set to 3.3V with a 9V battery connected

I've just found out that if I leave the circuit plugged in for a few minutes it begins to work which has completely lost me

One of these 9V batteries? Those lack the current capability to, reliably and for any length of time, supply current to a motor(s). You need a supply that can handle the combined stall currents of your motors. The stall current should be listed in the motor specification sheet.

What would you recommend to use? A cable to a plug?

Here is one way. How to make a schematic you can post.

Or study the schematic symbols and hand draw, photograph and post the schematic.

What are the voltage requirements of the project? Motor rated voltage? Motor stall current?

I would use a power supply capable of supplying the voltage and current to the motors and either a separate supply for the Arduino or supply the Arduino from a voltage converter from the motor supply voltage to the Arduino supply voltage.

1 Like

Ok thanks I will look into all that. But how come it works perfectly sometime, but then other times it does completely random stuff

you're missing a by-pass cap in schematic that you did not post, but then again

put your motor at rest for a little while at the end of the loop()

digitalWrite(A1A, 0);
digitalWrite(A1B, 0);
delay(1000);

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.