Controlling DC-motor by L293D Drive with Arduino Uno

 Controlling DC-motor by L293 Drive with Arduino Uno 

Hello guys 👋👋  welcome back again in today blog we will learn who to control DC motor with L293D drive the most famous drive in DC motor control in electronics , with Arduino Uno this blog is devided into three section in the first section we will learn the working principal and features of the Dc-motor , then in the next section we will explore the L293 drive architecture and functionality in controlling motors and the the third section we will discover who to control DC motor with it's drive with Arduino Uno board by setup the hardware configuration and writing the software code .


DC Motor Basics:


DC Motors are very simple rotary actuators that transform electrical energy into a mechanical rotation at a specific torque, Dc-motor are the most used motor in the electronics and embedded system projects for many reasons ,the  simplicity of control , thier high torque and also for thier low cost, it devide on 3 main parts :

DC motor


  1. Stator: The stationary part of the motor that produces a magnetic field.
  2. Rotor (Armature): The rotating part of the motor where the current flows, producing a magnetic field that interacts with the stator's field.
  3. Commutator and Brushes: The commutator reverses the direction of current flow through the rotor coils, ensuring continuous rotation. Brushes are used to transfer current to the rotating commutator.
When current flows through the rotor, it creates a magnetic field that interacts with the stator's magnetic field, producing torque that causes the rotor to rotate. The direction of rotation can be controlled by reversing the polarity of the current.,we find DC motors in several applications like (Robotics, Automation, DIY etc), controlling a DC motor includes: 

  1. controlling the motor’s speed 
  2. controlling the motor’s direction of rotation (CW or CCW). 

DC-motor Speed Control :

We can control the speed of the DC motor by simply controlling the input voltage to the motor and the most common is by using PWM signal.
Pulse Width Modulation (PWM) is a technique for generating a continuous HIGH/LOW alternating digital signal and programmatically controlling its pulse width and frequency. Certain loads like (LEDs, DC Motors, etc) will respond to the average voltage of the signal which gets higher as the PWM signal’s pulse width is increased
pulse width modulation is techniques for generating a continous pulses signal (on/off) with an defined frequency and duty cycle (On time of signal) according to the needs, the loads (motors ,leds ,etc) will received the average value of the signal so as the duty cycle is big (close to 1) as the average voltage is high and so On the pictures below show PWM technique
PWM techniques



DC-motor Direction Control:

or controlling the rotation direction, we just need to inverse the direction of the current flow through the motor, and the most common method of doing that is by using an H-Bridge. An H-Bridge circuit contains four switching elements, transistors or MOSFETs, with the motor at the center forming 
an H-like configuration. By activating two particular switches at the same time we can change the direction of the current flow, thus change the rotation direction of the motor.
So if we combine these two methods, the PWM and the H-Bridge, we can have a complete control over the DC motor. in the next section we will use L293D drive in order to control speed and direction of the a DC motor  


L293D Motor Drive:

The L293D is a dual channel H-Bridge IC capable of controlling two DC motors. The L293D can control up to two DC motors rated from 4.5V to 36V.

The schematic diagram below shows a simplified version of the internal circuitry that controls one motor:
L293D drive circuit



it composed from two  pairs of  transistors leg in order to set up a H-bridge. There’s a diode across the emitter and collector of each transistor, to prevent back EMF from the motor causing damage to the transistors.

When transistors Q1 and Q4 are both switched ON, and transistors Q2 and Q3 are OFF, current flows through the motor which will turn forward:
H bridge controlling Dc motor




When transistors Q2 and Q3 are ON, and Q1 and Q4 are OFF, the current through the motor is reversed. By reversing the current flow through the motor, the direction of its rotation will be reversed.
H bridge controlling Dc motor


the L293D also supports PWM (Pulse Width Modulation) signals for speed control. By varying the duty cycle of the PWM signal applied to the enable pin of the L293D, you can adjust the speed of the motor.
The L293D is a 16-pin IC, and in order to implement the drive with the motor we should know it's Pinout functionality:
L293D circuit


  • Pin 1 (Enable 1-2): Controls the operation of motor A ,if this pin is HIGH, the motor will be enabled; if LOW, the motor will be disabled.
  • Pin 9 (Enable 3-4): Controls the operation of motor B .
  • Pin 2 (Input 1): motor control signal for the first input of Motor A.
  • Pin 7 (Input 2): motor control signal for the second input of Motor A.
  • Pin 10 (Input 3): motor control signal for the first input of Motor B.
  • Pin 15 (Input 4): motor control signal for the Second input of Motor B.
  • Pin 3 (Output 1): Connected to one terminal of Motor A.
  • Pin 6 (Output 2): Connected to the other terminal of Motor A.
  • Pin 11 (Output 3): Connected to one terminal of Motor B.
  • Pin 14 (Output 4): Connected to the other terminal of Motor B.
  • Pins 4, 5, 12, and 13 (Ground Pins):connected to the ground .
  • Pin 8 (Vcc2):  motor supply voltage, it should be connected to the voltage required by the motors (4.5V to 36V).
  • Pin 16 (Vcc1): the logic supply voltage (5V), which powers the internal logic of the L293D

Interfacing L293D with Arduino:

Now we will make a small projects controlling a DC motor by L293D drive with arduino Uno:

in this project we will control both the speed and direction of DC motor using L293D drive with the following scenario:
speed Up the motor from 0 to full speed in forward direction 
then speed-down the motor from the full speed to 0 rpm in the reverse direction and repeat the cycle again (while loop).
we have developed this project in TinkerCad platfrom with following Circuit and schematics :
control Dc motor with L293D via arduino

L293D Dc motor schmatics







the arduino IDE software code is given below
control DC motor with arduino code



full project files (circuit ,schematics, code) are given in TinkerCad platform in the link attached below:

Don't forget to like and share this post and stay connecting with us for more exciting blogs 😎😎

Post a Comment

Previous Next

نموذج الاتصال