Strange problem with L293D h bridge

I connected like this, except the push button, for debugging. In the code, input 1 and enable 1 are always high, while input 2 is low.

The motor should spin, but nothing happens
I tied the following variations:

  • take out all the 3 inputs and connect either IN1 or IN2 to ground pin. Motor spins.
  • connect enable and either of the ip pins to vcc and the other one to ground. Motor spins.
  • connect them to digital pins and make enable=1 and either of inputs to 1 through code. Nothing happens.

So basically the h bridge works manually, but not with arduino pins. Did I miss something?

The outcome doesnt depend on whether an external power supply is connected.

I checked all the arduino pins with an LED. They seem to be working fine.

This was a part of my obstacle avoider robot. The panning servo and the ping sensor are working normally, its only the dc motors giving me nightmares

Take a look at this and see if you can spot the difference.

Not used to posting pictures so this might take a little work.

^ in your example, I1 is always connected to vcc (why through a resistor?) and I2 is always to ground. What if i want to change the direction?

Hi, what is supplying your arduino with power, and can you post a copy of your sketch.

Tom..... :slight_smile:

I tried these kinds of power supplies:

  • 4 AA NiMH batteries for arduino (multimeter showed some 5.6V) and 9V for h bridge.
  • USB for arduino and 4 AA NiMH batteries for motors.
  • everything on USB, when im really frustated (yes the motor actually runs if you connect either of in1 or in2 directly to ground)

The sketch is simple:

void setup() {
setMode(6,OUTPUT);// en1 pin
setMode(7,OUTPUT); //in 1
setMode(8,OUTPUT); // in2
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
//i guess 8 becomes LOW by defaut
}
void loop(){
}

Hi, aren't you using pins 2,3,4 as outputs? Not 6,7,8 as you have in your sketch?
Don't assume that a pin is low, set it low to be sure.

Tom.. Hope this helps.. :slight_smile:

Nope the pins are correct. The diagram I posted was just taken from Google as I hv never worked with fritzig before. I also tried a digitalWrite low on 8.

I wonder what's wrong with my h bridge which considers a logic 0 to be different from ground

OK I'll try one more time with a different one.

Can you spot the difference now?

Hi, sorry, pins 3,4 9 are output, 2 is input.
Also just spotted, pin 16 on L293D should be connected to 5V not the motor 9V supply.
With 9V logic, the 293 will need 9V from arduino to indicate a HIGH.
So disconnect pin16 from the battery and connect it to the 5V from the arduino.

Tom.... :slight_smile: (Good spot justone, must have had a HomerSimpson moment when I looked at the differences, just given you a karma, congratulations)

^Even the above circuit didnt work. Then I just connected my multimeter between input 1 of the H bridge, and ground to measure the voltage, and my car started moving all of a sudden and fell off the table along with the breadboard.

So I connected 2 10K resistors in parallel, between each of the 2 input pins of the h bridge and ground, and it works as expected. The enable pin somehow works even without the resistor.

Can you tell me why the resistors are needed? And why the pwm input works just fine without any resistor? I just made it work by hit and trial. I havent seen resistors attached anywhere on the internet.