Subscribe To Our List

We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
Email address
Secure and Spam free...

In this article, you are going to read in detail about controlling the motors using the L293D motor driver IC. The L293D IC is also known as the H-bridge IC. This IC is a very powerful IC and whenever you will want to control a DC motor or stepper motor or any other motor, then this IC will come in handy to you. It can control two motors running at 4.5 to 36V at a time and can control these in both clockwise and anti clockwise direction.

L293D Motor Driver IC

L293D motor driver IC is also known as H-bridge IC. It has 16 pins and it can control two DC motors at a time. It can control the DC motors in both clockwise and anti clockwise directions.

The reason to use it is that the Arduino can only provide output of 5V. So, if you want to control a 9V motor or a 12V motor then it cannot control it. To control these motors, we will have to use the L293D motor driver IC. It can also control the stepper motor or servo motor. It can control motors up to 36V. You can download the datasheet of L293D from here.

Specification

The specifications of the L293D motor driver IC are as follows.

Parameter Symbol Value Unit
Supply Voltage Vs 4.5 to 36 V
Logic Supply Voltage Vss 4.5 to 36 V
Enable Voltage Ven Up to 7 V
Output Current Io Up to 1.2 Ampere A
Storage or junction temperature Tstg -40 to 150 ◦C

Pin out

The pin out of the L293D IC is shown below.

  • EN1 and EN2 are the enable pins. If these pins will be high, then the motor will move otherwise the motors will not move.
  • IN1, IN2, IN3 and IN4 are the input pins. These pins will take input from the micro-controller and according to that the motor will move.
  • OUT1, OUT2, OUT3 and OUT4 are the output pins. The motors will be connected there.
  • Vs and Vss are the pins where we will give the input power.
  • The negative of the power source will be connected to the GND.
L293D motor driver IC Pin out

L293D pin out

Truth Table

The truth table will explain you that how to make connections for the motor if you want it to move in either clockwise or anti clockwise direction.

PIN 1 (Enable) PIN2 PIN7 OUTPUT
High High Low Turn Anti Clockwise
High Low High Turn Clockwise
High High Low Stop
High Low High Stop
Low Doesn’t matter Doesn’t matter Doesn’t matter

If the enable will be low, then the motor will not move in any of the case. If the enable will be high then the motor will move according to the connections of the pin 2 and pin 7. Same is the case for the enable 2 pin 10 and pin 14.

Circuit Diagram and Connections

First of all, we will connect the L293D motor driver IC with the Arduino. The connections are given below

  • Connect the pin 1 of the L293D IC the pin 7 of Arduino.
  • Connect the pin 2 of L293D to the pin 6 of the Arduino.
  • Connect the pin 3 of the L293D to one end of the motor.
  • Pins 4, 5, 12, 13 of L293D are the ground pins so connect these to ground.
  • Connect the pin 6 of the L293D to the other end of motor.
  • Connect the pin 7 to the pin 5 of Arduino.
  • Connect the VCC pins which are pin 8 and pin 16 of L293D to the positive rail.

After that, we will connect the push button with the Arduino. We need to just connect the two pins of push button. So, connect the one pin with the positive rail and the second pin with the pin 4 of Arduino as shown in the figure.

In last, connect the 9V battery or any DC power source from 6 to 12V to the positive rail and the ground rail as shown in the figure. Then connect the Vin of the Arduino to the positive rail and the ground of the Arduino to the ground rail.

l293d motor driver IC arduino

Circuit Diagram

Code

Before uploading the code to the Arduino, remove the battery wires and then upload the code from your PC to the Arduino using the cable. After uploading, remove the cable and connect the battery.

int PushButton_pin = 4; // Push button Pin
int Motor_Pin1 = 5; // pin 2 on L293D
int Motor_Pin2 = 6; // pin 7 on L293D
int Enable = 7; // pin 1 on L293D

void setup() {
    pinMode(PushButton_pin, INPUT);  //Setting the push button as the input pin
    //Setting the motor pins and the enable pin as the output pin
    pinMode(Motor_Pin1, OUTPUT);
    pinMode(Motor_Pin2, OUTPUT);
    pinMode(Enable, OUTPUT);
    digitalWrite(Enable, HIGH);  //Making the enable pin high to run the motor
}

void loop() {
    if (digitalRead(PushButton_pin) == HIGH) {  //Checking the state of the push button
        //Making one pin high and other low to run the motor
        digitalWrite(Motor_Pin1, LOW);
        digitalWrite(Motor_Pin2, HIGH);
    }

    //if the state of the push button will be low then the motor will not move
    else {
      //Making both the motor pins low to keep the motor at rest if the push button is not pressed.
        digitalWrite(Motor_Pin1, LOW);
        digitalWrite(Motor_Pin2, LOW);
    }
}

The code will look for the push button state. If you have pressed the push button, then the state will be high and the motor will move and if the push button is not pressed then the state will low and the motor will not move.

Video


If you have any questions, feel free to ask.

JOIN OUR NEWSLETTER
We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
We hate spam. Your email address will not be sold or shared with anyone else.

Leave a Reply

Your email address will not be published.

Subscribe To Our List

We help electronics hobbyists to create projects related to Micro-controllers. Join our newsletter to get access to new projects first.
Email address
Secure and Spam free...
Skip to toolbar