Experiment No 10 Student ID
Date Student Name
Interface DC Motor Control using L293D and Arduino
Aim/Objective:
The main objective of this experiment is to interface Control DC Motor using L293D and
Arduino Uno board.
Components required:
Software Hardware
Arduino UNO Board
Tinkercad Arduino UNO Cable
Arduino IDE (To be installed in Laptop) DC Motor-2
L293D Motor Driver
Potentiometer
Jumper wires
Description:
The L293D is a popular motor driver IC (Integrated Circuit) commonly used to control DC
motors with an Arduino UNO. It provides a convenient way to interface the Arduino with the
motor, allowing you to control its direction and speed. DC motor control using L293D and
Arduino UNO offers several benefits like: Compatibility Motor Protection, Bidirectional
ControlEasy Wiring, Multiple Motor Control, adjustable Speed Versatility.
Pre-Requisites:
1. Basics of Arduino Uno
2. Basics of DC Motor Control
Pre-Lab:
1. What is the purpose of the L293D IC in DC motor control using Arduino UNO
A) The L293D IC is a motor driver IC that is used to control the direction and speed of DC
motors when connected to an Arduino UNO. It provides the necessary circuitry to interface the
Arduino with the motors and allows bidirectional control.
2. How many DC motors can be controlled using a single L293D IC
A) The L293D IC can control two DC motors simultaneously. It has two H-bridge circuits,
each capable of controlling the direction and speed of one motor.
3. What are the main pins of the L293D IC used for motor control
A) The main pins of the L293D IC used for motor control are:
Enable pins (EN1 and EN2): These pins control the motor speed by providing a PWM signal
from the Arduino. Input pins (IN1, IN2, IN3, and IN4): These pins control the direction of the
motors.
4. How can you control the speed of a DC motor using the L293D and Arduino UNO
A) The speed of a DC motor can be controlled using the Enable pins (EN1 and EN2) of the
L293D IC. By providing a Pulse Width Modulation (PWM) signal from the Arduino to the
Enable pins, the average voltage applied to the motor can be varied, thus controlling the speed.
5. How can you change the direction of a DC motor using the L293D and Arduino UNO
A) The direction of a DC motor connected to the L293D IC can be changed by controlling the
input pins (IN1, IN2, IN3, and IN4). By setting the appropriate sequence of HIGH and LOW
signals on these pins, the motor can be rotated in either clockwise or counter clockwise
direction
In-Lab:
Program:
void setup()
{
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
}
void loop()
{
//clockwise, Anticlockwise & Stop of M1
digitalWrite(4, HIGH);digitalWrite(5, LOW); delay(3000);
digitalWrite(4, LOW);digitalWrite(5, HIGH); delay(3000);
digitalWrite(4, LOW);digitalWrite(5, LOW); delay(1000);
//clockwise, Anticlockwise & Stop of M2
digitalWrite(7, HIGH);digitalWrite(6, LOW); delay(3000);
digitalWrite(7, LOW);digitalWrite(6, HIGH); delay(3000);
digitalWrite(7, LOW);digitalWrite(6, LOW); delay(1000);
}
Connections Diagram (Tinkercad):
Connection Diagram (Hardware):
1. In the hardware setup, the L293D driver module will be connected as follows.
Enable pins, Connect “ + ”
to 5V, and other pin to
Ground
Connection
to 5V, and
Ground
Motor 1,
Positive and
Negative Motor 2,
pins Positive
and
Negative
pins
Input from Arduino, (As per our above programming):
First two pins for motor 1 (Arduino Pins 4, 5) &
Next two pins for motor 2 (Arduino Pins 6, 7)
2. Two DC Motors and Arduino board connections are as follows.
Schematic Diagram:
Procedure:
1. Give the connections to the Arduino board as shown in the connection diagram.
2. Open Arduino IDE in the computer
3. Create new file File_--→ New
4. Type your program and Save it in appropriate location in your computer.
5. Compile your program by clicking Verify option in the menu.
6. Once the program compiled successfully, connect the Arduino board to the computer using
USB cable.
7. After connecting, go to Tools ----→ Board ---→ Select Arduino/Genuino Uno option
8. After selecting board, go to Tools ----→ Port ---→ Select Arduino Uno COM port 3
(name may appear differently for other computers).
**Note that this port option will be displayed only when board is connected to computer
9. Now upload the program to the Arduino board by clicking Upload option.
10. Once the program uploaded successfully, observe the output on LCD.
Analysis and Inferences:
Results:
Sample VIVA-VOCE Questions:
1. What is the L293D IC?
A) The L293D is a popular integrated circuit (IC) commonly used for motor driver applications.
It can control the direction and speed of two DC motors or a stepper motor.
2. What is the purpose of the L293D in DC motor control?
A) The L293D acts as an H-bridge, which allows the Arduino to control the direction and speed
of the DC motor. It provides the necessary current and voltage levels to drive the motor.
3. How many motors can be controlled using the L293D IC?
A) The L293D IC can control up to two DC motors or one stepper motor.
4. What is an H-bridge?
A) An H-bridge is a circuit configuration that allows for controlling the direction of current
flow through a load, such as a motor. It consists of four switches (transistors or MOSFETs)
arranged in an "H" shape.
5. How does the L293D control the direction of the motor?
A) The L293D has two control pins, one for each motor. By setting the appropriate logic level
on these pins, the direction of the motor can be controlled. For example, setting one pin high
and the other low will make the motor rotate in one direction, and vice versa.
Post-Lab:
DC Motor Speed control using Potentiometer:
Program:
int Apin = A0; // Analog Input
int Ainput = 0; // Read analog input, initialized to zero
void setup()
{
pinMode(Apin, INPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop()
{
Ainput = analogRead(Apin);
int Speed = map(Ainput, 0, 1024, 0, 255);
delay(100);
analogWrite(9, Speed);
digitalWrite(10, HIGH);
}
Connection Diagram:
Evaluator Remark (if Any):
Marks Secured out of 50
Signature of the Evaluator with Date