Download as pdf or txt
Download as pdf or txt
You are on page 1of 52

A

PROJECT REPORT
ON

“ARDUINO OBSTACLE AVOIDING


CAR”
SUBMITTED FOR PARTIAL FULFILLMENT FOR AWARD THE DEGREE OF

BACHELOR OF TECHNOLOGY
IN
ELECTRICAL ENGINEERING

UNDER THE GUIDANCE OF


MR. RAJKUMAR BAGHEL

SUBMITTED BY
ABHISHEK KUMAR (1806520001)
BHUPENDER KUNTAL (1806520006)
GAURAV KUMAR (1806520010)
BIPIN CHAUDHARY (1806520007)

SUBMITTED TO

B.S.A. College of Engineering & Technology, Mathura


(Affiliated to Dr. A.P.J. Abdul Kalam Technical University, Lucknow)
SESSION 2020-2021
DECLARATION

We hereby declare that the project entitled “ARDUINO OBSTACLE


AVOIDING CAR” submitted for the partial fulfillment for award the
degree of BACHELOR OF TECHNOLOGY in ELECTRICAL
ENGINEERING is our original work and the project has not formed the
basis for the award of any degree, associateship, fellowship or any other
similar titles.

ABHISHEK KUMAR (1806520001)


BHUPENDER KUNTAL (1806520006)
GAURAV KUMAR (1806520010)
BIPIN CHAUDHARY (1806520007)

PLACE: Mathura (Uttar Pradesh)

DATE:

Department of Electrical Engineering Page i


BSACET, Mathura
B.S.A. College of Engineering & Technology, Mathura
Estd. & Governed by Shri Agrawal Shiksha Mandal
Approved by AICTE & PCI. Affiliated to AKTU & BTE, UP Lucknow

CERTIFICATE

Certified that ABHISHEK KUMAR, BHUPENDER KUNTAL, GAURAV


KUMAR, BIPIN CHAUDHARY has carried out the project work presented in
this report entitled “ARDUINO OBSTACLE AVOIDING CAR” for the
award of Bachelor of Technology (Electrical Engineering) from Dr. A.P.J. Abdul
Kalam Technical University, Lucknow under my supervision. The report
embodies result of original work and studies carried out by Students themselves.

Mr. Rajkumar Baghel Mr. Ram Chandra Gupta


(Project Guide) (H.O.D.)

Department of Electrical Engineering Page ii


BSACET, Mathura
ACKNOWLEDGEMENT

We wish to express our sincere thanks to our project guide Mr. Rajkumar
Baghel who contributed his precious time for the completion of this
project. We would like to pay our gratitude to our respected teachers of
Electrical Engineering Department.

Specially to Mr. Ram Chandra Gupta (H.O.D.) for their kind support.
We would also like to thank all our friends for giving their precious time
during the course of project. We are also very thankful to our family
members whose moral support cannot be neglected.

ABHISHEK KUMAR (1806520001)


BHUPENDER KUNTAL (1806520006)
GAURAV KUMAR (1806520010)
BIPIN CHAUDHARY (1806520007)

Department of Electrical Engineering Page iii


BSACET, Mathura
ABSTRACT

This Work is based on Arduino, motor driver, Ultrasonic Sensor and Servo Motor.
Arduino is an open source prototyping platform Based on easy-to-use hardware and
software. Arduino uses an ATmega328 microcontroller. Since robotics has become a
major part in our daily life and also in the engineering field and it plays a vital role in
the development of new technology. This project can be made in a bigger scale for
real time vehicles. This project describes about an obstacle avoidance robot vehicle
which is controlled by ultrasonic sensor. The robot is made using ultrasonic sensor
and it is controlled by Arduino microcontroller. Ultrasonic sensor fixed in front
portion of the robot vehicle.

The sensor gets the data from surrounding area through mounted sensors on the robot.
The sensor is sense the obstacle and deviate its path to choose an obstacle free path.
The sensor will be send the data to the controller is compared with controller to
decide the movement of the robot Wheel.

The robot wheel movement and direction will be based on the sensing of the
ultrasonic sensor and also using a wheel encoder. This vehicle is used for detecting
obstacle and avoiding the collision. We have programmed the controller to be used
with ANDROID app.

Department of Electrical Engineering Page iv


BSACET, Mathura
TABLE OF CONTENTS
Declaration i
Certificate ii
Acknowledgement iii
Abstract iv
Table of Contents v
Abbreviations vii
List of figures viii

Chapter 1 INTRODUCTION TO ARDUINO


1.1 What is Arduino?
1.2 Why Arduino?
1.3 Different Types of Arduino Boards
1.4 Arduino UNO Architecture & Pin Diagram
1.5 Features of Arduino Boards
1.6 How to program an Arduino?

Chapter 2 MOTOR DRIVER MODULE-L298N


AND SERVO MOTOR
2.1 Motor Driver Module - L298N
2.2 Controlling a DC Motor
2.3 L298N Motor Driver IC
2.4 Power Supply
2.5 Voltage Drop of L298N
2.6 Output Pins
2.7 Control Pins
2.8 L298N Motor Driver Module Pinout
2.9 Wiring L298N module with Arduino Uno

Chapter 3 DC GEAR BO-MOTOR AND BATTERY


3.1 DC Geared BO motor
3.2 Specifications of Motor and Tire Parameter
3.3 Features of BO Motors
3.4 Battery

Department of Electrical Engineering Page v


BSACET, Mathura
Chapter 4 WORKING AND ARDUINO CODING
5.1 Creating Interface by using RemoteXY App
5.2 Arduino Code – Controlling a DC Motor
5.3 Code Explanation
5.4 How to run it?
5.5 What is G sensor?
5.6 Application

Chapter 5 CONCLUSION
6.1 Conclusion

6.2 Future Work

References Some images of our Project Work

Department of Electrical Engineering Page vi


BSACET, Mathura
Abbreviations

Abbreviation Full Form


LED Light Emitting Diode
IDE Integrated Development Environment
IoT Internet of Things
3D Three Dimensional
I/O Input/Output
PWM Pulse Width Modulation
USB Universal Serial Bus
PC Personal Computer
AC Alternating Current
DC Direct Current
FTDI Future Technology Device International
I/P Input
O/P Output
GSM Global System for Mobile
SRAM Static Random Access Memory
EEPROM Electrically Erasable Programmable Read-Only Memory
ICSP In-Circuit Serial Programming
CPU Central Processing Unit
DIY Do it yourself
TTL Transistor-Transistor Logic
BO Battery Operated

Department of Electrical Engineering Page vii


BSACET, Mathura
Department of Electrical Engineering Page viii
BSACET, Mathura
CHAPTER – 1
INTRODUCTION TO ARDUINO

Department of Electrical Engineering Page 1


BSACET, Mathura
CHAPTER – 1
INTRODUCTION TO ARDUINO

1.1 What is Arduino?

Arduino is an ASCII text file natural philosophy platform based mostly on easy-to-use hardware
and software. Arduino boards are able to scan inputs light-weight on a device, a finger on a button,
or a message and switch it into an output activating a motor, turning on a semiconductor diode,
publication one thing online. We are able to tell our board what to try to by causation a collection of
directions to the microcontroller on the board. We have a tendency to use the Arduino artificial
language (based on Wiring), and therefore the Arduino software package (IDE), supported process.
Over the years Arduino has been the brain of thousands of projects, from everyday objects to
advanced scientific instruments. A worldwide community of manufacturer’s students, hobbyists,
artists, programmers, and professionals has gathered around this open- supply platform, their
contributions have grown up to an unimaginable quantity of accessible information that may be of
nice facilitate to novices and consultants alike.

Arduino was born at the Ivrea Interaction style Institute as a straightforward tool for quick
prototyping, aimed toward students while not a background in natural philosophy and
programming. As before long because it reached a wider community, the Arduino board started
ever-changing to adapt to new desires and challenges, differentiating its supply from
straightforward 8-bit boards to merchandise for IoT applications, wearable, 3D printing, and
embedded environments. All Arduino boards are fully ASCII text file, empowering users to make
them severally and eventually adapt them to their explicit desires. The software package, too, is
ASCII text file, and it's growing through the contributions of users worldwide.

1.2 Why Arduino?

Due to its straightforward and accessible user expertise, Arduino has been used in thousands of
completely different comes and applications. The Arduino software package is simple to use for
beginners, nevertheless versatile enough for advanced users. It runs on raincoat, Windows, and
Linux. Lecturers and students use it to build low price scientific instruments, to prove chemistry and
physics principles, or to urge started with programming and artificial intelligence. Designers and
architects build interactive prototypes, musicians and artists use it for installations and to
experiment with new musical instruments. Makers, of course, use it to make several of the comets
exhibited at the Maker Faire, as an example. Arduino could be a key tool to find out new things.
Anyone kids, hobbyists, artists, programmers will begin tinkering simply following the step by step
directions of a kit, or sharing ideas on-line with different members of the Arduino community.

There are several different microcontrollers and microcontroller platforms offered for physical
computing. Optical phenomenon Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard,
and many others supply similar practicality. All of these tools take the untidy details of
microcontroller programming and wrap it up in an easy-to-use package. Arduino additionally
simplifies the method of operating with microcontrollers; however it offers some advantage for
lecturers, students, and interested amateurs over different systems:

• Cheap - Arduino boards are comparatively cheap compared to different microcontroller


platforms. The least costly version of the Arduino module will be

assembled by hand, and even the pre-assembled.

Department of Electrical Engineering Page 2


BSACET, Mathura
• Cross-platform - The Arduino software package (IDE) runs on Windows, Macintosh OSX,
and operational system} operating systems. Most microcontroller systems are restricted to
Windows.
• Simple, clear programming setting – The Arduino software package (IDE) is simple to
use for beginners, nevertheless versatile enough for advanced users to benefit of further. For
teachers, it's handily supported the process programming setting, thus students learning to
program in this setting are acquainted with however the Arduino IDE works.
• Open supply and protractile software package - The Arduino software package is printed
as open supply tools, offered for extension by old programmers. The language is dilated
through C++ libraries, and folks eager to perceive the technical details will create the leap
from Arduino to the AVR-C artificial language on that it's based mostly.
• Open supply and protractile hardware - The plans of the Arduino boards are printed
underneath an original Commons license, thus old circuit designers will create their own
version of the module, extending it and up it. Even comparatively inexperienced users will
build the “breadboard version of the module” so as to grasp however it works and save
money.

1.3 Different Types of Arduino Boards


The Arduino boards includes the subsequent like

1. Arduino Uno (R3)


2. LilyPad Arduino Board
3. Red Board Arduino Board
4. Arduino Mega (R3) Board
5. Arduino Leonardo Board
6. The Arduino Shields

1. Arduino Uno (R3)

The Uno could be an immense choice for our initial Arduino. It consists of 14-digital I/O pins,
wherever 6-pins will be used as PWM outputs, 6-analog inputs, a push button, an influence jack, a
USB affiliation and additional. It includes everything needed to carry up the microcontroller;
merely attach it to a laptop with the assistance of a USB cable and provides the availability to urge
started with AN AC to DC adapter or battery.

Figure 1.1 Arduino Uno (R3)

Department of Electrical Engineering Page 3


BSACET, Mathura
2. LilyPad Arduino Board

The LilyPad Arduino board could be a wearable e-textile technology dilated by “Leah Buechley”
and with consideration designed by “Leah and SparkFun”. Every board was imaginatively designed
with immense connecting pads & a sleek back to allow them to be stitched into consumer goods
exploitation semi conductive thread. This Arduino additionally includes of I/O, power, and
additionally device boards that are designed particularly for e- textiles. These are even wash-and-
wear.

Figure 1.2 LilyPad Arduino Board

3. Red Board Arduino Board


The Red Board Arduino board is programmed employing Mini-B USB cable victimization the
Arduino IDE. It’ll work on Windows eight while not having to change our security settings. It’s a
lot of constant thanks to the USB or FTDI chip we have a tendency to use and conjointly it's
entirely flat on the rear. It’s terribly straightforward to utilize within the project style. Simply plug
the board; choose the menu choice to select an Arduino UNO and prepared to transfer the program.
We are able to management it over USB cable victimization the barrel jack.

Figure 1.3 Red Board Arduino Board

4. Arduino Mega (R3) Board


The Arduino Mega is analogous to the UNO’s huge brother. It includes immeasurable digital I/O
pins (from that, 14-pins is used as PWM O/P), 6-analog inputs, a push button, an influence jack, a
USB affiliation and a push button. It includes everything needed to carry up the microcontroller;
merely attach it to a computer with the assistance of a USB cable and provides the provision to
induce started with AN AC to DC adapter or battery. the large no. of pins create this Arduino board
terribly useful for coming up with the comets that require a bunch of digital I/P or O/P like tons
buttons.

Department of Electrical Engineering Page 4


BSACET, Mathura
Figure 1.4 Arduino Mega (R3) Board

5. Arduino Leonardo Board


The first development board of AN Arduino is that the Leonardo da Vinci board. This board uses
one microcontroller at the side of the USB. It’s terribly straightforward and low-cost conjointly. As
a result of this board handles USB directly, program libraries square measure procurable that let the
Arduino board to follow a keyboard of the PC, mouse, etc.

Figure 1.5 Arduino Leonardo Board

6. The Arduino Shields


Additionally, Arduino shields square measure pre designed circuit boards wont to connect with
variety of Arduino boards. These shields match on the highest of the Arduino compatible boards to
produce a further capability like connecting to the net, motor dominant, providing wireless
communication, alphanumeric display screen dominant, etc. the various sorts of AN Arduino
shields are- Wireless Shields, GSM Shield, local area network protect, early Shields.

Figure 1.6 Arduino Shields

Department of Electrical Engineering Page 5


BSACET, Mathura
1.4 Arduino UNO Architecture & Pin Diagram

1.4.1 Arduino Architecture:


Arduino’s processor essentially uses the Harvard design wherever the program code and program
knowledge have separate memory. It consists of 2 memories- Program memory and also the
knowledge memory. The code is hold on within the flash program memory, whereas (the
knowledge the info the information) is hold on within the data memory. The Atmega328 has 32 KB
of non-volatile storage for storing code (of that 0.5 KB is employed for the boot loader), 2 KB of
SRAM and 1 KB of EEPROM and operates with a clock speed of 16MHz.

Figure 1.7 Arduino Architecture

1.4.2 Arduino Pin Diagram


Arduino Uno consists of fourteen digital input/output pins (of that 6 is used as PWM outputs), 6
analog inputs, a sixteen megahertz quartz oscillator, a USB affiliation, an influence jack, AN ICSP
header, and a push button.

Department of Electrical Engineering Page 6


BSACET, Mathura
• Power Jack: Arduino is power either from the computer through a USB or through external
supply like adapter or a battery. It will operate an external provider of 7V to 12V. Power is
applied outwardly through the pin Vin or by giving voltage reference through the IORef pin.
• Digital Inputs: It consists of fourteen digital inputs/output pins, every of which offer or take
up 40mA current. a number of them have special functions like pins zero and one, that act as
Rx and American state severally , for serial communication, pins two and 3-which square
measure external interrupts, pins 3,5,6,9,11 that provides PWM output and pin thirteen
wherever crystal rectifier is connected.
• Analog inputs: Its 6 analog input/output pins, every providing a resolution of ten bits.
• ARef: It provides relevance the analog inputs.
• Reset: It resets the microcontroller once low.

Figure 1.8 Arduino Pin Diagram

1.5 Features of Arduino Boards


The table given below shows the features of Arduino Boards.

Arduino Board Processor Memory Digital I/O Analogue I/O


Arduino Uno 16Mhz 2KB SRAM, 14 6 input,
ATmega328 32KB flash 0 output
Arduino Due 84MHz 96KB SRAM, 54 12 input,
AT91SAM3X8 512KB flash 2 output
E
Arduino Mega 16MHz 8KB SRAM, 54 16 input,
ATmega2560 256KB flash 0 output
Arduino Leonardo 16MHz 2.5KB 20 12 input,
ATmega32u4 SRAM, 32KB 0 output
flash

Table 1.1 Arduino Board Features

Department of Electrical Engineering Page 7


BSACET, Mathura
1.6 How to program an Arduino?
The most necessary advantage with Arduino is that the programs is directly loaded to the device
while not requiring any hardware applied scientist to burn the program. This can be done
attributable to the presence of the zero.5KB of Boot loader that permits the program to be burned
into the circuit. All we've to try and do is to transfer the Arduino code and writing the code.

Figure 1.9 Arduino Software Interface

The Arduino tool window consists of the toolbar with the buttons like verify, upload, new, open,
save, serial monitor. It conjointly consists of a text editor to write down the code, a message space
that displays the feedback like showing the errors, the text console that displays the output and a
series of menus just like the File, Edit and Tools menu.
1.6.1 Steps to program an Arduino
 Programs written in Arduino are called sketches. A basic sketch consists of three elements
1. Declaration of Variables
2. Initialization: It's written within the setup () perform.
3. Management code: It's written within the loop () perform.
 The sketch is saved with .ino extension. Any operations like collateral, gap a sketch, saving
a sketch will be done mistreatment the buttons on the toolbar or mistreatment the tool menu.
 The sketch is to be keep within the sketch pad directory.
 Choose the right board from the tools menu and therefore the interface numbers.
 Click on the transfer button or selected transfer from the tools menu. So the code is
uploaded by the boot loader onto the microcontroller.

Department of Electrical Engineering Page 8


BSACET, Mathura
1.6.2 Few of basic Arduino functions are:
 digitalRead(pin): Reads the digital value at the given pin.
 digitalWrite(pin, value): Writes the digital value to the given pin.
 pinMode(pin, mode): Sets the pin to input or output mode.
 analogRead(pin): Reads and returns the value.
 analogWrite(pin, value): Writes the value to that pin.
 serial.begin(baud rate): Sets the beginning of serial communication by setting the bit rate.

1.6.3 Reasons why Arduino is being preferred these days


1. It's cheap.
2. It comes with an open supply hardware feature that allows users to develop their own kit
mistreatment already obtainable one as a reference supply.
3. The Arduino code is compatible with all sorts of operational systems like Windows, Linux,
and Macintosh etc.
4. It conjointly comes with open supply code feature that allows older code developers to use
the Arduino code to merge with the prevailing artificial language libraries and might be
extended and changed.
5. It's straightforward to use for beginners.
6. We will develop AN Arduino primarily based project which might be utterly stand alone or
comes that involve direct communication with the code loaded within the laptop.
7. It comes with a straightforward provision of connecting with the electronic equipment of the
pc mistreatment serial communication over USB because it contains in-built power and reset
electronic equipment.

Department of Electrical Engineering Page 9


BSACET, Mathura
Department of Electrical Engineering Page 10
BSACET, Mathura
CHAPTER – 2
MOTOR DRIVER MODULE L298N

AND

SERVO MOTOR

Department of Electrical Engineering Page 11


BSACET, Mathura
CHAPTER – 2
MOTOR DRIVER MODULE L298N

2.1 Motor Driver Module L298N


The L298N is an integrated monolithic circuit in a 15- lead Multiwatt and PowerSO20 packages. It
is a high voltage, high current dual full-bridge driver de-signed to accept standard TTL logic level
sand drive inductive loads such as relays, solenoids, DC and stepping motors. Two enable inputs
are provided to enable or disable the device independently of the input signals.
The emitters of the lower transistors of each bridge are connected together rand the corresponding
external terminal can be used for the connection of an external sensing resistor. An additional
Supply input is provided so that the logic works at a lower voltage. Its schematic diagram is as
shown in figure 3.1.

Figure 3.1 Schematic diagram of Motor Drive Module

2.2 Controlling a DC Motor

In order to have a complete management over DC motor, we tend to have to management its speed
and rotation direction. This may be achieved by combining these 2 techniques.

2.2.1PWM – For controlling speed

The speed of a DC motor may be controlled by varied its input voltage. A typical technique for
doing this can be to use PWM (Pulse breadth Modulation). PWM could be a technique wherever

Department of Electrical Engineering Page 12


BSACET, Mathura
average price of the input voltage is adjusted by causation a series of ON-OFF pulses. The common
voltage is proportional to the breadth of the pulses called Duty Cycle.

The higher the duty cycle, the bigger the average voltage being applied to the dc motor (High
Speed) and therefore the lower the duty cycle, the less the common voltage being applied to the dc
motor (Low Speed).

Below figure illustrates PWM technique with varied duty cycles and average voltages.

Figure 3.2 Pulse Width Modulation (PWM) Techniques

2.2.2 H-Bridge – For controlling rotation direction

The DC motor’s spinning direction may be controlled by dynamic polarity of its input voltage. A
common technique for doing this can be to use Associate in Nursing H-Bridge. Associate in
Nursing H-Bridge circuit contains four switches with the motor at the middle forming Associate in
Nursing H-like arrangement. Closing 2 specific switches at the same time reverses the polarity of
the voltage applied to the motor. This causes amendment in spinning direction of the motor. Below
figure illustrates H-Bridge circuit operating.

Figure 3.3 Working of H-Bridge


Department of Electrical Engineering Page 13
BSACET, Mathura
2.3 L298N Motor Driver IC

Figure 3.4 L298N Chip

At the center of the module is that the huge, black chip with chunky conductor is Associate in
Nursing L298N.

The L298N could be a dual-channel H-Bridge motor driver capable of driving a try of DC motors.
That means that it will on an individual basis drive up to 2 motors creating it ideal for building two-
wheeled mechanism platforms.

2.4 Power Supply

The L298N motor driver module is battery-powered through three-pin 3.5mm-pitch screw
terminals. It consists of pins for motor power offer (Vs), ground and 5V logic power offer (Vss)

Figure 3.5 Power supply port in L298N Motor Drive Module

NOTE: The L298N motor driver IC really has 2 input power pins viz. ‘Vss’ and ‘Vs’. From Vs pin
the H-Bridge gets its power for driving the motors which might be five to 35V. Vss is employed for
driving the logic electronic equipment which might be five to 7V. And that they each sink to a
typical ground named ‘GND’.

Department of Electrical Engineering Page 14


BSACET, Mathura
The module has an on-board 78M05 5V regulator from STMicroelectronics. It can be enabled or
disabled through a jumper.

When this jumper is in place, the 5V regulator is enabled, supplying logic power supply (Vss) from
the motor power supply (Vs). In this case, 5V input terminal acts as an output pin and delivers 5V
0.5A. We can use it to power up the Arduino or other circuitry that requires 5V power supply.

When the jumper is removed, the 5V regulator gets disabled and we have to supply 5 Volts
separately through 5 Volt input terminal.

WARNING: We can put the jumper in place, if the motor power supply is below 12V. If it is
greater than 12V, we should remove the jumper to avoid the onboard 5V regulator from getting
damaged.
Also DO NOT supply power to both the motor power supply input and 5V power supply input
when jumper is in place.
2.5 Voltage Drop of L298N
The voltage drop of the L298N motor driver is about 2V. This is due to the internal voltage drop in
the switching transistors in the H-Bridge circuit. So, if we connect 12V to the motor power supply
terminal, the motors will get voltage around 10V. This means that a 12V DC motor will never spin
at its peak speed.

To get peak speed out of motor, the motor power supply should be bit higher voltage (2V) than
motor’s actual voltage requirement.

Considering the voltage drop of 2V, if we are using 5V motors we’ll need to provide 7V at motor
power supply terminal. If we have 12V motors then our motor supply voltage should be 14V.

Figure 3.6 Checking Voltage Drop in L298N Motor Drive Module

Department of Electrical Engineering Page 15


BSACET, Mathura
2.6 Output Pins
The L298N motor driver’s output channels for the motor A and B are broken out to the edge of the
module with two 3.5mm-pitch screw terminals. We can connect two DC motors having voltages
between 5 to 35V to these terminals.

Each channel on the module can deliver up to 2A to the DC motor. However, the amount of current
supplied to the motor depends on system’s power supply.

Figure 3.7 Output pins of L298N Motor Drive Module

2.7 Control Pins


For each of the L298N’s channels, there are two types of control pins which allow us to control
speed and spinning direction of the DC motors at the same time viz. Direction control pins & Speed
control pins.

2.7.1 Direction Control Pins

Figure 3.8 Direction Control pins of L298N Motor Drive Module

Using the direction control pins, we can control whether the motor spins forward or backward.
These pins actually control the switches of the H-Bridge circuit inside L298N IC. The module has
two direction control pins for each channel. The IN1 and IN2 pins control the spinning direction of
the motor A while IN3 and IN4 control motor B. The spinning direction of a motor can be
controlled by applying either a logic HIGH (5 Volts) or logic LOW (Ground) to these inputs. The
below chart illustrates how this is done.

Department of Electrical Engineering Page 16


BSACET, Mathura
Input1 Input2 Spinning Direction

Low(0) Low(0) Motor OFF


High(1) Low(0) Forward
Low(0) High(1) Backward
High(1) High(1) Motor OFF

Table 3.1 Controlling motor’s spinning direction with control inputs

2.7.2 Speed Control Pins

The speed control pins viz. ENA and ENB are used to turn the motors ON, OFF and control its
speed. Pulling these pins HIGH will make the motors spin, pulling it LOW will make them stop.
But, with Pulse Width Modulation (PWM), we can actually control the speed of the motors. The
module usually comes with a jumper on these pins. When this jumper is in place, the motor is
enabled and spins at maximum speed. If we want to control the speed of motors programmatically,
we need to remove the jumpers and connect them to PWM-enabled pins on Arduino.

Figure 3.9 Speed Control pins of L298N Motor Drive Module

2.8 L298N Motor Driver Module Pinout


1. VCC pin supplies power for the motor. It can be anywhere between 5 to 35V. Remember, if
the 5V-EN jumper is in place, we need to supply 2 extra volts than motor’s actual voltage
requirement, in order to get peak speed out of our motor.
2. GND is a common ground pin.
3. 5V pin supplies power for the switching logic circuitry inside L298N IC. If the 5V-EN
jumper is in place, this pin acts as an output and can be used to power up our Arduino. If the
5V-EN jumper is removed, we need to connect it to the 5V pin on Arduino board.
4. ENA pins are used to control speed of Motor A. Pulling this pin HIGH (Keeping the jumper
in place) will make the Motor-A spin, pulling it LOW will make the motor stop. Removing
the jumper and connecting this pin to PWM input will let us control the speed of Motor-A.
5. IN1 & IN2 pins are used to control spinning direction of Motor-A. When one of them is
HIGH and other is LOW, the Motor-A will spin. If both the inputs are either HIGH or LOW
the Motor-A will stop.
6. IN3 & IN4 pins are used to control spinning direction of Motor-B. When one of them is
HIGH and other is LOW, the Motor-B will spin. If both the inputs are either HIGH or LOW
the Motor-B will stop.

Department of Electrical Engineering Page 17


BSACET, Mathura
7. ENB pins are used to control speed of Motor-B. Pulling this pin HIGH (Keeping the jumper
in place) will make the Motor-B spin, pulling it LOW will make the motor stop. Removing
the jumper and connecting this pin to PWM input will let us control the speed of Motor-B.
8. OUT1 & OUT2 pins are connected to Motor-A.
9. OUT3 & OUT4 pins are connected to Motor-B.

Figure 2.8 L298N Module Pinout

2.9 Wiring L298N module with Arduino Uno


Now we have knowledge about the module, we can begin hooking it up to our Arduino board. Start
by connecting power supply to the motors. In our project we are using DC Gearbox Motors (also
known as ‘BO’ motors) that are usually found in two-wheel drive robots. They are rated for 3 to
12V. So, we will connect external 12V power supply to the Vcc terminal. Considering internal
voltage drop of L298N IC, the motors will receive 10V and will spin at slightly lower RPM. But,
that’s OK.

Next, we need to supply 5 Volts for the L298N’s logic circuitry. We will make use of the on-board
5V regulator and derive the 5 volts from the motor power supply so, keep the 5V-EN jumper in
place.

Now, the input and enable pins (ENA, IN1, IN2, IN3, IN4 and ENB) of the L298N module are
connected to six Arduino digital output pins (6, 7, 8, 9, 10 and 11). Note that the Arduino output
pins 10 and 11 are both PWM-enabled.

Finally, connect one motor to terminal A (OUT1 & OUT2) and the other motor to terminal B
(OUT3 & OUT4). We can interchange our motor’s connections; technically, there is no right or
wrong way.

When we’re done we should have something that looks similar to the figure shown below.

Department of Electrical Engineering Page 18


BSACET, Mathura
Figure 2.9 Connection diagram of project

Department of Electrical Engineering Page 19


BSACET, Mathura
SERVO MOTOR

A servomotor is a rotary actuator or linear actuator that allows for precise

control of angular or linear position, velocity and acceleration. It consists of

a suitable motor coupled to a sensor for position feedback.

Department of Electrical Engineering Page 20


BSACET, Mathura
CHAPTER – 3
DC GEAR BO-MOTOR AND BATTERY

Department of Electrical Engineering Page 21


BSACET, Mathura
CHAPTER – 3
DC GEAR BO-MOTOR AND BATTERY

3.1 DC Geared BO motor


A DC in gear BO motor could be a easy DC motor with gear box hooked up to the shaft of the
motor that is automatically commutated motor hopped-up from electricity (DC).

Figure 3.1 DC Gear BO Motor

3.2 Specifications of Motor and Tire Parameter


Motor Parameter:
1. Voltage: DC 3V-6V
2. Current: 100 mA-120 mA
3. Reduction rate: 48: one
4. Revolutions per minute (With tire): 100-240
5. Tire Diameter: 65mm
6. Automotive Speed (M/minute): 20-48
7. Motor Weight (g): 29/each
8. Motor Size: 70mm × 22mm × 18mm
9. Noise: <65dB
Tires Parameter:
1. Centre Hole: five.3mm × 3.66mm
2. Wheel size: 65mm × 26mm

3.3 Features of BO Motors


 Gear materials: Plastic.
 Motor types: Permanent-magnet.
 Brush-type: Brush.

Department of Electrical Engineering Page 22


BSACET, Mathura
 Uncommitted motors: Homopolar motors.
 Magnet types: ferrite magnets.
 Torque multiplication: Generate a large force at a low speed.
 Cost effectiveness of the injection-molding process.
 Elimination of machining operations.
 Low density: lightweight, low inertia.
 Uniformity of parts.
 Capability to absorb shock and vibration as a result of elastic compliance.
 Ability to operate with minimum or no lubrication, due to inherent lubricity.
 Relatively low coefficient of friction.
 Corrosion-resistance; elimination of plating, or protective coatings.
 Quietness of operation.
 Tolerances often less critical than for metal gears, due in part to their greater
resilience.
 Consistency with trend to greater use of plastic housings and other components.

3.4 Battery
For the running of this project we have use a power bank instead of any battery which is an
advantage to this project. It can be charged by USB data cable and can be used as per the need.
Some of the technical specification of the power bank is given below.

GENERAL

Brand Xiaomi

FEATURES

Over Current Protection Yes


Led Indicators Yes
Fast Charge Yes
Over Charge Protection Yes

BATTERY CHARGING

AC Adaptor Charging, Charging time: 3.5 Hours, USB


Charging Type Time Charging, Charging time: 5.5 Hours
Battery Type Li-Polymer
Capacity 10000 mAh

Department of Electrical Engineering Page 23


BSACET, Mathura
CONNECTIVITY

Connector Type USB 2.0


No. of Output Ports 1

POWER REQUIREMENTS

Power Input 12 V
Power Output 12 V

Figure 4.2 Power Bank

Department of Electrical Engineering Page 24


BSACET, Mathura
CHAPTER – 4
WORKING AND ARDUINO CODING

Department of Electrical Engineering Page 25


BSACET, Mathura
CHAPTER – 4
WORKING AND ARDUINO CODING

The obstacle avoidance robotic vehicle uses ultrasonic sensors for its

movements. A microcontroller of 8051 family is used to achieve the desired

operation. The motors are connected through motor driver IC

microcontroller. The ultrasonic sensor is attached in front of the robot. Whenever

the robot is going on the desired path the ultrasonic sensor transmits the

ultrasonic waves continuously from its sensor head. Whenever an obstacle

comes ahead of it the ultrasonic waves are reflected back from an object and that

information is passed to the microcontroller. The microcontroller controls the

motors left, right, back, front based on ultrasonic signals. In order to control the

speed of each motor pulse width modulation is used (PWM).

The aim of this project is to implement an obstacle avoiding robot using ultrasonic

sensor and Arduino. All the connections are made as per the circuit diagram. The

working of the project is explained below.

Department of Electrical Engineering Page 26


BSACET, Mathura
When the robot is powered on, both the motors of the robot will run normally and

the robot moves forward. During this time, the ultrasonic sensor continuously

calculate the distance between the robot and the reflective surface.

This information is processed by the Arduino. If the distance between the robot

and the obstacle is less than 15cm, the Robot stops and scans in left and right

directions for new distance using Servo Motor and Ultrasonic Sensor. If the

distance towards the left side is more than that of the right side, the robot will

prepare for a left turn. But first, it backs up a little bit and then activates the Left

Wheel Motor in reversed in direction.

Similarly, if the right distance is more than that of the left distance, the Robot

prepares right rotation. This process continues forever and the robot keeps on

moving without hitting any obstacle.

CODING OF ARDUINO

//AFMotor Library https://learn.adafruit.com/adafruit-motor-shield/library-install //

//NewPing Library https://github.com/eliteio/Arduino_New_Ping.git //

//Servo Library https://github.com/arduino-libraries/Servo.git //

#include <AFMotor.h>

Department of Electrical Engineering Page 27


BSACET, Mathura
#include <NewPing.h>

#include <Servo.h>

#define TRIG_PIN A0

#define ECHO_PIN A1

#define MAX_DISTANCE 100

#define MAX_SPEED 150 // sets speed of DC motors

#define MAX_SPEED_OFFSET 20

NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE);

AF_DCMotor motor1 (1, MOTOR12_64KHZ);

AF_DCMotor motor2 (2, MOTOR12_64KHZ);

AF_DCMotor motor3 (3, MOTOR34_64KHZ);

AF_DCMotor motor4 (4, MOTOR34_64KHZ);

Servo myservo;

boolean goes Forward=false;

int distance = 100;

int speed Set = 0;

void setup() {

myservo.attach(10);

Department of Electrical Engineering Page 28


BSACET, Mathura
myservo.write(115);

delay(2000);

distance = readPing();

delay(100);

distance = readPing();

delay(100);

distance = readPing();

delay(100);

distance = readPing();

delay(100);

void loop() {

int distanceR = 0;

int distanceL = 0;

delay(40);

if(distance<=25)

Department of Electrical Engineering Page 29


BSACET, Mathura
{

moveStop();

delay(100);

moveBackward();

delay(200);

moveStop();

delay(200);

distanceR = lookRight();

delay(200);

distanceL = lookLeft();

delay(200);

if(distanceR>=distanceL)

turnRight();

moveStop();

Department of Electrical Engineering Page 30


BSACET, Mathura
else

turnLeft();

moveStop();

else

moveForward();

distance = readPing();

int lookRight()

myservo.write(50);

Department of Electrical Engineering Page 31


BSACET, Mathura
delay(500);

int distance = readPing();

delay(100);

myservo.write(115);

return distance;

int lookLeft()

myservo.write(170);

delay(500);

int distance = readPing();

delay(100);

myservo.write(115);

return distance;

delay(100);

Department of Electrical Engineering Page 32


BSACET, Mathura
int readPing() {

delay(100);

int cm = sonar.ping_cm();

if(cm==0)

cm = 250;

return cm;

void moveStop() {

motor1.run(RELEASE);

motor2.run(RELEASE);

motor3.run(RELEASE);

motor4.run(RELEASE);

void moveForward() {

Department of Electrical Engineering Page 33


BSACET, Mathura
if(!goesForward)

goesForward=true;

motor1.run(FORWARD);

motor2.run(FORWARD);

motor3.run(FORWARD);

motor4.run(FORWARD);

for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2) // slowly bring the speed up to

avoid loading down the batteries too quickly

motor1.setSpeed(speedSet);

motor2.setSpeed(speedSet);

motor3.setSpeed(speedSet);

motor4.setSpeed(speedSet);

delay(5);

Department of Electrical Engineering Page 34


BSACET, Mathura
}

void moveBackward() {

goesForward=false;

motor1.run(BACKWARD);

motor2.run(BACKWARD);

motor3.run(BACKWARD);

motor4.run(BACKWARD);

for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2) // slowly bring the speed up to

avoid loading down the batteries too quickly

motor1.setSpeed(speedSet);

motor2.setSpeed(speedSet);

motor3.setSpeed(speedSet);

motor4.setSpeed(speedSet);

delay(5);

Department of Electrical Engineering Page 35


BSACET, Mathura
void turnRight() {

motor1.run(FORWARD);

motor2.run(FORWARD);

motor3.run(BACKWARD);

motor4.run(BACKWARD);

delay(500);

motor1.run(FORWARD);

motor2.run(FORWARD);

motor3.run(FORWARD);

motor4.run(FORWARD);

void turnLeft() {

motor1.run(BACKWARD);

motor2.run(BACKWARD);

motor3.run(FORWARD);

motor4.run(FORWARD);

Department of Electrical Engineering Page 36


BSACET, Mathura
delay(500);

motor1.run(FORWARD);

motor2.run(FORWARD);

motor3.run(FORWARD);

motor4.run(FORWARD);

Department of Electrical Engineering Page 37


BSACET, Mathura
CHAPTER – 5
CONCLUSION

Department of Electrical Engineering Page 38


BSACET, Mathura
CHAPTER – 5
CONCLUSION

5.1Conclusion
The Arduino is an open source device that has been the brain for numerous projects. The Arduino
has everything that is required by the user which includes its inbuilt converter, I/P pins etc. With the
combination of Arduino, and the Bluetooth Shield we can control over many other things, like
home Lightings, air conditioner and many more through our cell phones. The Arduino can also
contribute at large for the Smart Home system. By doing this Project we found out a lot about the
Arduino, and how it has made us easier to convert digital signals into physical movements. One
more advantage of Arduino is that once a program is burned we don‘t need to worry about the
program getting erased as long as it is not RESET. Arduino has also over all other microcontroller
because of its efficiency and user friendly property.

5.2Future Work

In the process of development of the Arduino Based Car Controlling System Using G-Sensor, most
of the useful feature is identified and many of them were implemented. But due to the time
limitations and other factor some of these cannot be added.
So the development features in brief:
 A Robot Mounted with camera
 A headset, with a full-color display
 A mission control centre

APPLICATIONS

 Obstacle avoiding robots can be used in almost all mobile robot navigation
systems.
 They can be used for household work like automatic vacuum cleaning
 They can also be used in dangerous environments, where human penetration
could be fatal.
 The modification of this logic code is used in vacuum cleaners.
 This robot can be used for avoiding concealed paths, such as an industrial
robot in a factory is expected to avoid workers so that it won’t hurt them

 It will be very useful in parking system.


Department of Electrical Engineering Page 39
BSACET, Mathura
 It can also be used in assembling automobiles and in chemical industries.

 If there is an obstacle in the root of the robot, it can detect and avoid it. Thus it
can move without having damaged by any obstacle which makes it more
reliable.
 They have great importance in scientific exploration and emergency rescue,
there may be places that are dangerous for humans or even impossible for
humans to reach directly, then we should use robots to help us gather
information to about their surrounding challenging environments.

THANKU YOU

Department of Electrical Engineering Page 40


BSACET, Mathura
Department of Electrical Engineering Page 41
BSACET, Mathura
Department of Electrical Engineering Page 42
BSACET, Mathura
Department of Electrical Engineering Page 43
BSACET, Mathura

You might also like