Professional Documents
Culture Documents
Arduino DC Motor Speed and Direction Control With L293D
Arduino DC Motor Speed and Direction Control With L293D
Submitted by
BONAFIDE CERTIFICATE
my supervision.
SIGNATURE SIGNATURE
ABSTRACT
TABLE OF CONTENTS
ABSTRACT iv
1 INTRODUCTION 1
2 LITERATURE SURVEY 2
3 MODULES 3
3.1 Project Description
3.2 Circuit Diagram
3.3 Required Components
3.4 Circuit Design
3.5 Working Process
3.6 Code
APPENDIX 11
REFERENCES 13
v
INTRODUCTION
DC Motors are further classified in to different types like series, shunt and
compound and each type is used in different areas of applications. Some DC
motors are also used in Robotic and Industrial applications for their easy
control and precision.
LITERATURE SURVEY
vii
PROJECT DESCRIPTION
DC Motors are further classified in to different types like series, shunt and
compound and each type is used in different areas of applications. Some DC
motors are also used in Robotic and Industrial applications for their easy control
and precision.
CIRCUIT DIAGRAM
ix
REQUIRED COMPONENTS
Arduino UNO
L293D Motor Driver IC
10KΩ Potentiometer
Push button X 2
12V DC Motor
12V DC Adapter
Connecting Wires
x
COMPONENT DESCRIPTION
Arduino UNO
CIRCUIT DESIGN
As mentioned earlier, Arduino UNO and L293D Motor Driver IC are the
main components of the circuit. Arduino UNO acts as the main
processing part of the circuit. A button and a potentiometer are used to
control the direction of rotation and speed of the motor respectively.
Hence, a button is connected to Pin 13 of Arduino for driving the motor
in forward direction and another button is connected to Pin 12 of Arduino
for driving the motor in reverse direction with the other terminals of both
the buttons connected to ground.
A potentiometer i.e. the wiper terminal of the pot is connected to analog
input pin A0 of the Arduino UNO. The other terminals of the
potentiometer are connected to 5V supply and ground respectively.
L293D is a 16-pin IC available in dual in-line package. As it is capable
of driving two motors, we’ll see the connections that are needed for
driving a single motor. In that,
Pin 1 of L293D IC is used to enable the driver channels 1 and 2 i.e. inputs
of motor 1. It is an active high pin and hence it is connected to 5V supply.
Pins 2 and 7 of L293D are inputs of drivers associated with motor 1. They
are connected to Pins 11 and 10 of Arduino UNO respectively.
Pins 3 and 6 of L293D are the output pins of first driver channel. They
must be connected to the motor we are going to control.
Pins 4, 5, 12 and 13 of the L293D IC are ground pins.
The remaining connections with respect to L293D IC are the power
supply pins. L293D Motor Driver IC needs two types of power: one for
its internal operations and other for driver channels that drive the motor.
Pin 16 of L293D IC is the supply pin for internal operations and is
connected to a 5V supply. Pin 8 of L293D IC is the supply for driving the
motor and is connected to a 12V supply.
xii
WORKING PROCESS
The aim of this project is to design an Arduino based system for controlling a
DC Motor. All the connections are made as per the circuit diagram mentioned
above. The working of the project is very simple and is explained here.
Two buttons are used in this project, one each for forward and reverse direction
of the motor. The two buttons are connected to Pins 13 and 12 of Arduino which
are internally pulled-up (using code). The other terminals of the buttons are
connected to ground and hence when the button is pressed, the microcontroller
detects LOW (logic 0).
The output of the POT is an analog signal and hence it is connected to analog
pin of the Arduino. Based on the analog voltage value from the POT, the speed
of the motor is varied.
For this to happen, we need to use the concept of PWM in the circuit. The inputs
to the motor driver IC must be in the form of a PWM signal and hence are
connected to Pins 11 and 10 of Arduino respectively, which are capable of
generating PWM signals.
When the system is powered ON, Arduino waits for the button to be pressed. If
the forward direction button is pressed, the Arduino drives input 1 of motor
driver IC (Pin 2) with PWM signal and a logic low to input 2 (Pin 3). Hence,
the motor starts rotating in forward direction.
Similarly, if the reverse direction button is pressed, Arduino drives input 2 (Pin
3) of L293D Motor Driver IC with the PWM signal and input 1 (pin 2) of
L293D is given a logic low. Hence, the motor starts rotating in reverse
directions.
The speed of the motor in either direction can be controlled using the POT as
it controls the duty cycle of the output PWM signal.
xiii
CODE
constintpotPin = A0;
constintfwdbuttonPin = 13;
constintbckbuttonPin = 12;
constint pin1 = 11;
constint pin2 = 10;
intpotValue = 0;
intmotorValue = 0;
intfwdbuttonState = 0;
intbckbuttonState = 0;
void setup()
{
pinMode(fwdbuttonPin, INPUT_PULLUP);
pinMode(bckbuttonPin, INPUT_PULLUP);
pinMode (pin1, OUTPUT);
pinMode (pin2, OUTPUT);
void loop()
{
potValue = analogRead(potPin);
motorValue = map(potValue, 0, 1023, 0, 255);
fwdbuttonState = digitalRead(fwdbuttonPin);
xiv
bckbuttonState = digitalRead(bckbuttonPin);
if (fwdbuttonState == LOW)
{
analogWrite(pin1, motorValue);
digitalWrite (pin2, LOW);
analogWrite(pin2, motorValue);
digitalWrite (pin1, LOW);
else
{
}
xv
APPENDIX
xvi
xvii
xviii
REFERENCES
1. https://www.electronicshub.org/dc-motor-control-arduino/
2. https://simple-circuit.com/arduino-dc-motor-speed-direction-control-
l293d/