In this blog, we will discuss about L293D Pin Diagram its working, and its interfacing with Arduino. L293D can drive two DC motors simultaneously, with up to 600mA current in each channel. It receives a control signal from microcontrollers such as Arduino, ESP32 Dev Module, etc. based on these control signals it controls the direction of rotation of the DC motors. also, we can control the speed of the DC motors by applying the PWM signal at Enable pins shown in the pin diagram of L293D of the Motor Driver IC L293D. Now I’ll explain to you why I had said that it’s magical IC because of its Dual H-Bridge Configuration it can operate over two voltages i.e. we can apply 4.5V to 36V at pin 8 and to run the whole IC 5V should be applied at pin 16.
In this article, we are going to learn about the Pin Diagram of L293D, Functions of pins L293D, Working Principle of L293D, and Interfacing of L293D with Arduino and their code.
L293D Pin Diagram of Motor Driver IC
L293D Pin Diagram Description:
The functions of all 16 pins which are mentioned in the above pin diagram of L293D is given below.
Enable 1-2 (Pin No. 1)-:
This pin is an active-high when it receives high or logic 1 then it enables the left part of the ic and when it receives active low i.e. logic 0 or low voltage then the left part of the ic won’t work. (in short, it enablers the left part of the ic) At the end of the pin description, there are two important notes. Please read this carefully.
Input 1 (Pin No. 2)-:
This is an input pin to control the direction of the left motor. (Control signal received from a microcontroller or microprocessor)
Output 1 (Pin No. 3)-:
It’s connected to one of the terminals of the motor and it’s is high when input 1 is high else it will be low.
Ground (Pin No. 4 & 5)-:
Both pins are for heat sink and ground pins. (because its drive two motors that’s why it has an extra load to compensate that load it has two pins as heat sink otherwise the ic gets overheated and burn out)
Output 2 (Pin No. 6)-:
It’s connected to the second terminals of the motor and it’s is high when input 2 is high else it will be low.
Input 2 (Pin No. 7)-:
This is an input pin to control the direction of the left motor. (Control signal received from a microcontroller or microprocessor)
Vcc 2 (Pin No. 8)-:
Connected to the power supply of range 4.5V to 36V. this voltage used to drive or to run both motors
Enable 3-4 (Pin No. 9)-:
This pin is an active-high when it receives high or logic 1 then it enables the right part of the IC and when it receives active low i.e. logic 0 or low voltage then the right part of the IC won’t work. (in short, it enables the right part of the IC )
Input 3 (Pin No. 10)-:
This is an input pin to control the direction of the right motor. (Control signal received from a microcontroller or microprocessor)
Output 3 (Pin No. 11)-:
It’s connected to one of the terminals of the motor and it’s is high when input 3 is high else it will be low.
Ground (Pin No. 12 & 13)-:
Both pins are for heat sink and ground pins. (because its drive two motors that’s why it has an extra load to compensate that load it has two pins as heat sink otherwise the ic gets overheated and burn out)
Output 4 (Pin No. 14)-:
It’s connected to the second terminals of the motor and it’s is high when input 4 is high else it will be low.
Input 4 (Pin No. 15)-:
This is an input pin to control the direction of the right motor. (Control signal received from a microcontroller or microprocessor)
Vcc 1 (Pin No. 16)-:
It provides power to the L293D IC. So, this pin should be supplied with 5V. if this pin is not powered with 5V then the whole IC will not work.
Note:
1-: Enable 1-2 and Enable 3-4 are also used to control the speed of the dc motor. if you apply PWM signal to these enables pins then the Motor Driver IC L293D can control the speed of both motors. if you apply the PWM signal to enable 1-2 then the speed of the left motor can be controlled, if you apply the PWM signal to enable 3-4 then the speed of the right motor can be controlled.
2-: Because the Motor Driver L293D IC has to deal with high currents, it features four ground pins. As a result, a heat sink is required to limit the amount of heat generated while also protecting the IC from damage. We get a huge metallic space between the grounds where the heat can be discharged when we solder these pins on the PCB.
Features of Motor Driver IC L293D
- Simultaneously Drives two DC motors in direction.
- Voltage Range: 4.5 V to 36 V (Vcc 2)
- High-Noise-Immunity Inputs
- Separate Input-Logic Supply
- Output Current 600mA Per Channel
- Internal ESD(Electrostatic Discharge) Protection
Working of L293D motor driver IC:
Motor Driver IC L293D is running on the basic principle of H-Bridge, IC L293D has two-channels. It consists of H-Bridge circuit in each channel therefore it’s known as Dual H-Bridge Motor Driver IC L293D. The circuit diagram of the H-Bridge is given below, the circuit diagram consists of four switches to control the direction of rotation of the motor. To understand the circuit diagram in a better way we will consider the following conditions.
-
When Switch S1 & S4 Closed, a positive voltage is applied across the motor and it will rotate in a clockwise direction and when both switches are open, the motor will stop rotating.
-
When Switch S2 & S3 Closed, an inverting voltage is applied at the terminals of the motor and it will rotate in an anti-clockwise direction and when both switches are open, the motor will stop rotating.
H-Bridge Circuit Diagram
-
When Switches S1 & S3 are closed, the motor receives positive voltage at both terminals, forcing the motor to burn out due to excessive heat.
-
When Switches S2 & S4 are closed, the motor receives negative voltage at both terminals, forcing the motor to burn out due to excessive heat.
-
When Switches S1 & S2 are closed, the power supply gets shorted.
- When Switches S3 & S4 are closed, the power supply gets shorted.
Interfacing of L293D With Arduino:
The Connections are shown in the below figure. by referring to that connection you can run your DC motor in any direction (i.e. Forward, Backward, Right, and Left). The Arduino is powered using a USB, and pin 16 of L293D is receiving 5V from the Arduino output pin 5v. The 9V battery is directly connected to pin number 8 of L293D.
The output pins (3, 6, 11, & 14) of L293D are connected to DC Geared Motor.
The input pins (2, 7, 10, & 15) of L293D are connected to Arduino pins (5, 4, 3, & 2) respectively.
The Enable 1-2 & Enable 3-4 of L293D are connected to 5V.
The Following code you can paste into your Arduino IDE and experience the working of the above circuit.
#define m1 2
//for controlling the direction of upper motor
#define m2 3
//for controlling the direction of upper motor
#define m3 4
//for controlling the direction of lower motor
#define m4 5
//for controlling the direction of lower motor
void setup ()
{
//Setup of pin mode, either they are working as Input or Output.
pinMode(m1, OUTPUT);
pinMode(m2, OUTPUT);
pinMode(m3, OUTPUT);
pinMode(m4, OUTPUT);
}
void loop()
{
//Condition for forward
digitalWrite(m1, HIGH);
digitalWrite(m2, LOW);
digitalWrite(m3, HIGH);
digitalWrite(m4, LOW);
delay(10000); //delay of 10 second.
//Condition for backward
digitalWrite(m1, LOW);
digitalWrite(m2, HIGH);
digitalWrite(m3, LOW);
digitalWrite(m4, HIGH);
delay(10000);
//Condition for RIGHT
digitalWrite(m1, HIGH);
digitalWrite(m2, LOW);
digitalWrite(m3, LOW);
digitalWrite(m4, LOW);
delay(10000);
//Condition for LEFT
digitalWrite(m1, LOW);
digitalWrite(m2, LOW);
digitalWrite(m3, HIGH);
digitalWrite(m4, LOW);
delay(10000);
//Condition for STOP
digitalWrite(m1, LOW);
digitalWrite(m2, LOW);
digitalWrite(m3, LOW);
digitalWrite(m4, LOW);
delay(10000);
}
Enjoy learning.