Arduino L293D DC motors control

A long time ago, i wrote a little tutorial on how to use a L298 Dual H-bridge motor driver, but i thought i could go further and this time I tried with a L293D chip.

The L293D Chip is a Dual H-Bridge Motor Driver for DC or Step motors. It can handle two Motors or one step motor. It can power motors until 36V and 600mA of steady current  – Max of 1.2A.

The chip is easy to use and takes little space

In this tutorial will see how to use it to power 1 or 2 DC Motors

NOTE: If you don’t want to mess with ICs and need a more easy approach, I recommend Grove I2C Motor Driver from Seeed. It’s easy to use and very straightforward.

In a few weeks, will create something awesome with it.


  • L293D chip
  • Arduino (I’m using UNO)
  • 2x DC Motors
  • 4x AA batteries and holder

First, here’s the chip


and the specs – the darker small semi-circle is on the TOP –


A little explanation on the Chip PINs

NOTE: As you can see, L293D as two power PINs – 8 (+Vmotor) and 16 (+V). The PIN 8 provides power for the motors ( Separate power source) and the PIN 16 provides power for the chip (provided by the Arduino)

Motor control PINs

EN1 Enable Motor 1
EN2 Enable Motor 2
IN1 Direction 1 Motor A
IN2 Direction 2 Motor A
IN3 Direction 1 Motor B
IN4 Direction 2 Motor B

PIN values and meaning to the bridge and motors

PIN Value
IN1 HIGH Enables Motor A
LOW Disables Motor A
IN2 HIGH Enables Motor B
LOW Disables Motor B
IN1 HIGH Motor A Forward
IN1 LOW Motor A Backwards
IN1 LOW Motor A Stops

The same happens when using EN3 and EN4


The wiring is simple, but requires atention. Here’s a schematic from Fritzing (click the image for a bigger version)


A table with the connections

L293 PIN Arduino PIN
EN1 5
IN1 6
IN2 7
EN2 8
IN3 9
IN4 10

NOTE: In the code i’ve used digitalWrite to enable the IN(x) PINs, but you can use analogWrite (and change INx PINS to PWM PINs) and use values from 0-255 to control speed.


Here’s the code for the programm

This way, you can use a simple chip to control 2 DC Motors.


Happy coding


11 Replies to “Arduino L293D DC motors control

  1. This explanation was very useful. I finally managed to get my 2WD robot car going. Especially the info that explains which pins to use for the motor direction helped me. I was also hesitating whether or not to use two batteries (one for Arduino, one for motors) but after seeing this I tested it with 4xAA and it worked just fine. Next step for me will be trying to use PWM and adding a power switch.

  2. can i get complete code with Analogwrite and pins …. i have used same configuration but it’s not working , i have powered up my motors with external power of 9v battery …..

    1. Hi Ali.

      The full code is on the page. If you wanna try with Analog PINs, just exchange the 4 PINs controlling the motors with A0, A1…A5 and give it a try.

      Swap the 9v battery for another… Are you sure the battery has charge ?
      Best regards

  3. The code works. However when I use a 9v battery connector to the board the motors dont reverse. Why is that?

    1. Hello !
      In what PIN of the LD293D chip are you powering your circuit ? Do you have enough power ? Are you powering the circuit with an external source (just for the motors) or with the Arduino ?

      Best regards

    1. Hi JarrettF !

      Just use another L293D to control the other two motors. Replicate the schematic with other Arduino PINS – If you want them to move at the same time, connect them to the same PINs as the first one..

  4. Hi, we wired it the way you said to do it but one of the motors aren’t turning and everything is wired correctly, and the code is the exact same as yours. What do we do?

    1. Hello Mimi !
      A lot of things could be wrong. That code works – using external power for the motors. Are you sure everything is wired correctly ? Just like the sketch ?
      Are the batteries OK ? Do they have charge ?
      Are the motors OK ?
      Is the LD293D chip in working order ?
      Are you providing power for the arduino ? Is the breadboard working ?

      If you have a multimeter? If so, please check if the motores are receiving power – measure in the motors connection pads.
      Try and wire only one motor at a time

      Any more questions please let me now ! Thank you

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.