Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

ARDUINO DC MOTOR SPEED AND DIRECTION

CONTROL WITH L293D

MINOR PROJECT REPORT

Submitted by

Aashna Bansal (RA1611003010746)


Muskan Lawania (RA1611003010786)
Tanya Agarwal (RA1611003010941)

15CS376L Minor Project ll

DEPARTMENT OF COMPUTER SCIENCE AND


ENGINEERING

FACULTY OF ENGINEERING AND TECHNOLOGY


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
KATTANKULATHUR- 603 203
April 2019
ii

BONAFIDE CERTIFICATE

Certified that this project report titled “ARDUINO DC MOTOR

SPEED AND DIRECTION CONTROL WITH L293D” is the

bonafide work of “Aashna Bansal (RA1611003010746), Muskan

Lawania (RA1611003010786) and Tanya Agarwal

(RA1611003010941)” who carried out the minor project work under

my supervision.

SIGNATURE SIGNATURE

Mrs.K.R.Jansi Dr. Annie Uthra


Assistant Professor, Associate Professor,
Department of CSE, Department of CSE,
SRMIST/KTR SRMIST/KTR
iii

ABSTRACT

A DC Motor is a type of electric motor that converts DC electrical power


to mechanical power i.e. a DC supply is converted to rotation or movement.
DC motors are one of the commonly used motors in different applications like
electronic toys, power tools, portable fans, etc.
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.
Since DC motors are generally associated with small to medium applications,
where the system mainly consists of a Microcontroller as the main processing
unit, controlling and driving a DC motor is very important. This is because,
driving a motor directly using the microcontroller is not advised (sometimes
not possible) as the current from the Microcontroller is very small (usually less
than 30mA).
In this project, a small DC Motor is controlled with an Arduino and a Motor
Driver IC where both the speed of the motor and the direction of rotation are
controlled.
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.
iv

TABLE OF CONTENTS

CHAPTER NO. TITLE PAGE NO.

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

A DC Motor is a type of electric motor that converts DC electrical power to


mechanical power i.e. a DC supply is converted to rotation or movement. DC
motors are one of the commonly used motors in different applications like
electronic toys, power tools, portable fans, etc.

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.

Since DC motors are generally associated with small to medium applications,


where the system mainly consists of a Microcontroller as the main processing
unit, controlling and driving a DC motor is very important. This is because,
driving a motor directly using the microcontroller is not advised (sometimes
not possible) as the current from the Microcontroller is very small (usually
less than 30mA).

In this project, a small DC Motor is controlled with an Arduino and a Motor


Driver IC where both the speed of the motor and the direction of rotation are
controlled.
vi

LITERATURE SURVEY
vii

PROJECT DESCRIPTION

A DC Motor is a type of electric motor that converts DC electrical power to


mechanical power i.e. a DC supply is converted to rotation or movement. DC
motors are one of the commonly used motors in different applications like
electronic toys, power tools, portable fans, etc.

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.

Since DC motors are generally associated with small to medium applications,


where the system mainly consists of a Microcontroller as the main processing
unit, controlling and driving a DC motor is very important. This is because,
driving a motor directly using the microcontroller is not advised (sometimes
not possible) as the current from the Microcontroller is very small (usually less
than 30mA).

In this project, a small DC Motor is controlled with an Arduino and a Motor


Driver IC where both the speed of the motor and the direction of rotation are
controlled.
viii

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

Arduino UNO is a simple electronics prototyping based on ATmega328P


Microcontroller. It is an 8-bit AVR based microcontroller that acts as the brain
of the Arduino UNO. Arduino UNO boards are frequently used in many entry
level applications like controlling LEDs, driving motors to high end
applications like weather monitoring, handheld gaming consoles etc.

L293D Motor Driver IC

As the name suggests, L293D is a quadruple H-bridge, high current motor


driver IC. It can be used to drive two motors at a time in both the directions
with an output current of 600mA for each motor. L293D IC is designed to drive
relays, DC motors, stepper motors and other inductive loads with high current
and high voltage requirements.
xi

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);

else if (bckbuttonState == LOW)


{

analogWrite(pin2, motorValue);
digitalWrite (pin1, LOW);

else
{

digitalWrite (pin1, LOW);


digitalWrite (pin2, LOW);

}
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/

You might also like