L293D - Spin DC motor backwards

I've wired a small 6v DC motor up to an L293D chip and it works perfectly in one direction.

I currently have the power to leg #2 set to high and leg #7 set to low via the digital output pins on my Arduino. This makes the motor spin anti-clockwise, and I believe that reversing these (2 = low / 7 = high) should reverse the spin of the motor and turn it clockwise.

For some reason this doesn't work at all, and just produces absolutely no movement.

I've attached a simple schematic showing the wiring for the circuit, and I've included the code below. I've checked all the connections and everything is definitely wired up correctly.

Does anybody have any ideas? It's driving me crazy that I can't get this thing to spin the other way!

int enablePin = 5;
int directPinA = 4;
int directBPinB = 3;

void setup() {
  pinMode(enablePin,OUTPUT);
  pinMode(directPinA,OUTPUT);
  pinMode(directPinB,OUTPUT);
}

void loop() {
  
  digitalWrite(directPinA,HIGH);
  digitalWrite(directPinB,LOW);

  digitalWrite(enablePin,HIGH);

}

OPs image so we don't have to download.
See this handy image guide.

Oh cool, thanks!

I'll bear that in mind for the future.

stotty146:
Does anybody have any ideas? It's driving me crazy that I can't get this thing to spin the other way!

Physically reverse the wires to the motor, and see if it's actually capable of running the other way. (Or do that just with a battery and no Arduino / 293)

If that's ok (or even before) check the polarity of the 293's output with your meter or an led with resistor.

Hi,
Have you got hte gnd of the 293 connected to the gnd of the UNO, and have you got pin16 of the 293 connected to 5V of the UNO to supply the 293 driver logic.
Check my additions to your circuit.



Tom... :slight_smile:

TomGeorge:
Have you got hte gnd of the 293 connected to the gnd of the UNO

Hi Tom,

Turns out this was the issue!

Apologies for the rookie mistake, I'm still completely new to this. I connected the GND rail on the breadboard (supplied by an external module) to the GND pin on my Arduino and the motor now spins in either direction as expected.

Thanks very much for helping :slight_smile: lesson learn to always connect the grounds when using external power!

Thanks,
Chris

Hi ,
Good to hear, yes a simple mistake, but you learn from them.

What is the next stage of your motor driving exploration?

Tom... :slight_smile:

I'm going to start experimenting with servo's next!

I've got a little joystick too, so I've seen some cool ideas online where I should be able to make a simple controllable arm with a couple of servos.

TomGeorge:
Have you got hte gnd of the 293 connected to the gnd of the UNO...

This was my problem also as the tutorial does not include it. It works perfectly after making this correction.

But how come, at least in OP's case, not sure about franticlamb's, it worked in even one direction?