Professional Documents
Culture Documents
Jimma University: Jimma Institute of Technology (Jit)
Jimma University: Jimma Institute of Technology (Jit)
Jimma University: Jimma Institute of Technology (Jit)
ADVISOR:
Isayiyas Nigatu
Feb, 1/ 2016
JIMMA UNIVERSITY, JIT
JIMMA, ETHIOPIA
Car Collision Avoidance System using Arduino and ultrasonic sensor 2016
GROUP MEMBERS
№ Name ID e-mail Phone №
1 Bazezew Mulu 01230/04 bazezewm@gmail.com +251923778512
2 Husen Oli 02165/04 Livefortomorrow172@gmail.com +251917260419
3 Berhanu Girma 01290/04 brenegn@gmail.com +251926149580
4 Alhamdu Menji 01014/04 +251923695442
5 Daniel Abate 01442/04 danielabate60@gmail.com +251913605458
Declaration
We declare that the work entitled Car Collision Avoidance System using Arduino and
ultrasonic sensor is our original work. We have not copied from any other students’ work or from any
other sources except where due reference or acknowledgement is made explicitly in the text, nor has any
part been written for us by another person.
We are:
Bazezew Mulu Berhanu Girma
Signature: __________ signature: ____________
Alhamdu Menji Daniel Abate
Signature: __________ signature: _____________
Husen Oli
Signature: _________
Advisor’s Declaration
Isayiyas Nigatu
Signature: ____________________
Hereby certifies that the work entitled Car Collision Avoidance System using Arduino and
ultrasonic sensor was prepared by the above named student, and was submitted to the School of
Electrical and Computer Engineering (ECEg), JIT as a partial/full fulfillment for the
conferment of BSC and the aforementioned work, to the best of our knowledge, is the said
student’s work.
Acknowledgment
We have immense pleasure in expressing our thanks and deep sense of gratitude to our advisor
Intr. Isayiyas Nigatu for his constructive suggestion and critically reviewing of this proposal. Without
his help this project would not have been possible. We would also acknowledge the School of Electrical
and Computer Engineering for allowing us to do this proposal. We also express our sincere thanks to
Mr. Solomon for extending his help and we express our great thank to all members of school
staff for their valuable advice and help to complete the project successfully.
Finally, we would like to thank everybody who was important to the successful realization of the project,
as well as expressing our apology that we could not mention personally one by one.
Abstract
Car collision avoidance system is a safety feature in cars to avoid colliding with
a vehicle or an obstacle in the way. The main objective of this system is to help driver
prevent car collisions due to blind spots and their carelessness while driving. We use different
components on this project such as Arduino 2560p microcontroller, four ultrasonic sensors,
Buzzer and LCD display. The sensors in the car would be capable of detecting even in the poor
conditions and would inform the driver distance from the various objects around the car which
will help the driver to drive safely in such poor conditions and a central Arduino microcontroller
would also be able take decisions according to different situations.
In the proposed work the system is going to be implemented using ARDUINO 2560
microcontroller along with ultrasonic sensor module. The control unit is the main processing unit
through which all the other modules are connected. The ultrasonic sensor modules HC - SR04 is
a high range sensor. This sensor module is implemented in the front and back of the vehicle
which serves as backward and forward vehicle collision avoidance. The other two right and left
side sensor modules HC - SR04 are used in such a way that they can detect the obstacle in blind
spot of the vehicle. The sensor can detect the distance between the vehicle and the obstacle. The
calculated distance can be displayed on the LCD and a buzzer is blown to alert the driver if the
distance between the obstacle and vehicle crosses the minimum safe distance.
Contents
Declaration ................................................................................................................................................... iii
Acknowledgment ......................................................................................................................................... iv
Abstract ......................................................................................................................................................... v
List of figure ............................................................................................................................................... viii
List of Table .................................................................................................................................................. ix
Acronyms ...................................................................................................................................................... x
CHAPER ONE ................................................................................................................................................. 1
1. Introduction .......................................................................................................................................... 1
1.1 Background ................................................................................................................................... 1
1.2 Project Objective ........................................................................................................................... 2
1.2.1 General Objective ................................................................................................................. 2
1.2.2 Specific Objective: ................................................................................................................. 2
1.3 Statement of the problem and motivation ................................................................................... 2
1.4 Scope of the project ...................................................................................................................... 2
1.5 Methodology of the study ............................................................................................................ 2
CHAPTER TWO .............................................................................................................................................. 4
2 LITRATURE REVIW ................................................................................................................................. 4
2.1 Related Work ................................................................................................................................ 4
2.2 Hardware Components we use..................................................................................................... 4
2.2.1 The Arduino AT mega 2560p................................................................................................. 5
2.2.2 Ultrasonic sensor (Module HC - SR04) .................................................................................. 8
2.2.3 Liquid crystal displays (LCD) ................................................................................................ 11
2.2.4 Power Supply ...................................................................................................................... 13
2.2.5 Buzzer .................................................................................................................................. 13
CHAPTER THREE .......................................................................................................................................... 14
3 System design and Simulation Results................................................................................................ 14
3.1 BLOCK DIAGRAM ......................................................................................................................... 14
3.2 Working principle of the system ................................................................................................. 14
3.3 System design and implementation ........................................................................................... 15
3.3.1 Hardware Design ................................................................................................................. 15
3.3.2 Software Design .................................................................................................................. 17
3.4 System Implementation .............................................................................................................. 17
List of figure
Figure 2-1 Internal structure of arduino 2560 ............................................................................................... 6
Figure 2-2 ultrasonic sensor .......................................................................................................................... 9
Figure 2-3 Timing diagram ......................................................................................................................... 10
Figure 2-4 LCD display .............................................................................................................................. 11
Figure 3-1ultrasonic sensor placement on car............................................................................................. 15
Figure 3-2 Circuit Diagram of the overall system ...................................................................................... 18
Figure 3-3 simulation result of the project .................................................................................................. 19
List of Table
Table 2-1 specification of Arduino 2560 ...................................................................................................... 8
Table 2-2 module PIN definition .................................................................................................................. 9
Table 2-3 specification of ultrasonic sensor (HC - SR04) .......................................................................... 10
Table 2-4 Mechanical Data of LCD 16x4 Display ..................................................................................... 11
Table 2-5 Electrical Characteristics of LCD ............................................................................................... 12
Table 2-6 Interface Pin Function of LCD [5] ............................................................................................. 13
Table 3-1estimated cost .............................................................................................................................. 19
Acronyms
AC alternate current
AREF analog reference
CM centimeter
DB data bus
DC direct current
EEPROM electrical erasable programmable read only memory
GND ground
IDE integrated drive electronics
I/O input/output
IR infrared
KB kilobit
LCD liquid crystal display
LED light emitting diode
mA miliampere
mm millimeter
MHz megahertz
PWM pulse width modulation
RADAR radio detection and ranging
RS reset
R/W read/write
Rx receiver
SRAM static random access memory
TX transmitter
USB universal serial bus
CHAPER ONE
1. Introduction
The increasing demand for flexibility as well as technological Even though there are several
advanced technological innovations are available today for vehicle safety, the growth in the
number of accidents is continues regularly. And most of these accidents are especially due to
collision or intersectional accidents carelessness of the deriver.
1.1 Background
With the emerging of new technologies in different field of science the human life has become
more comfortable and effortless. Advancement of embedded technologies in automotive
industries makes the human life safer and convenient for living. According to a survey large
numbers of deaths in Ethiopia which are caused by road accidents. The obstacle detection in real
time is the most versatile and challenging task for road vehicle and passenger safety.[1][3][7]
The first obstacle detection system was developed by Delco System Operations, Goleta of
California in 1988. This system was basically a safety system which detects the obstacle on rad
and alerts the driver. This system was also capable of detecting the moving objects on nearby
lane. After this system, another object detection technique is implied in automotive that make use
of infrared sensor, radar and ultrasound sensors.[3]
The increasing demand of embedded technologies in automotive industry provides a better and
reliable safety feature for the passenger and driver safety. A number of obstacle detection system
are introduced which provides safety measures and increase the transport efficiency.
Autonomous vehicle technology are implemented in most of the vehicles nowadays which
includes a number of sensors to detect the obstacles in front , side and rear of the vehicle . The
main work of this paper contributes to the detection of obstacles in lateral blind spot of the
vehicle and in front of the vehicle. The system will alert the driver so that the driver
may apply brakes or steer the wheels and avoid collision. In this proposed ultrasonic sensor are
planned to be implant for the detection purpose as they can detect the object very close to the
vehicle and have an immediate response and generates an accurate distance between the obstacle
and the vehicle.[1][3]
Our proposed collision avoidance system is operates in the following way: ultrasonic sensors are
placed in all directions of the vehicle and these sensors are regularly scans the road ahead for
obstacles or vehicles and if any obstacle or vehicle find, then warning is given to the driver. If
any vehicle is very near than predefined threshold value then automatically the ARDUINO 2560
made a decision and display the output of the sensor on the LCD display and the buzzer alert the
driver. [7]
Complete layout of the whole setup will be drawn inform of a block diagram.
The ultrasonic sensor will first sense the obstacle and give its output to the Arduino
microcontroller & the ARDUINO UNO displays respective distance output of the
ultrasonic sensor on the LCD
Start
Project Review
Integrate the
system
Check the design
Is the simulation
work?
End
CHAPTER TWO
2 LITRATURE REVIW
2.1 Related Work
Previous works of obstacle detection involves the use of infrared sensors which were widely
used as proximity sensor for obstacle avoidance. As IR sensor resembles nonlinear behavior and
the basic concept depends on the reflection from surrounding object, it produces error in the
measured distance. So these sensors were not reliable for precise measurements. Thus these
sensors are suitable only for short distance measurement up to 25 cms. [1][3][7]
The image/vision technologies are also introduced for pedestrian safety and detection. It is the
most challenging task as fast processing is needed to alert the driver as soon as possible.
Pedestrian has to be detected in every frame in which it appears. But the system using
image/vision technologies have some drawbacks. The system fails in some unfriendly whether
situations like fog, harsh and extreme rainy environment. The system sometimes produces error
to differentiate between shadows and pedestrian. The system requires high resolution cameras
and implementation of such system is a difficult task as it produces error due to damping and
vibrations of the vehicles. [3]
Recently ultrasonic sensors and radar sensors are used for obstacle detection techniques in
vehicles .The advanced driver assistance system uses RADAR because of its long detectable
range and higher reliability. The LiDAR sensors are to use to scan road boundaries and detects
obstacle and generate a safe vehicle path. The downward looking LiDAR sensors are used to
detect the obstacle and detect the road side boundaries. But implementation of such system is not
easy as it consumes more power and has higher cost, so ultrasonic sensors are better approach for
obstacle detection.[3][7]
ARDUINO ATmega2560
Ultrasonic sensor (module HC-SR04)
Crystal liquid display (LCD) (16x4)
Buzzer
power supply
This project uses The Arduino Mega 2560 to controls the motor. Follow the schematic to connect
the Arduino to the ultrasonic sensor, and the ultrasonic sensor measure the relative distance from
the obstacle. The Arduino Board is programmed using the Arduino IDE software. [9]
Performance
The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V,
however, the 5V pin may supply less than five volts and the board may be unstable. If using
more than 12V, the voltage regulator may overheat and damage the board. The recommended
range is 7 to 12 volts.
The Mega2560 differs from all preceding boards in that it does not use the FTDI USB-to-serial
driver chip. Instead, it features the Atmega8U2 programmed as a USB-to-serial converter.
The Arduino 2560 has several different kinds of pins each of which is labeled on the board and
use for different functions.
• VIN.The input voltage to the Arduino board when it's using an external power source (as
opposed to 5 volts from the USB connection or other regulated power source). You can supply
voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.
• 5V.The regulated power supply used to power the microcontroller and other components on the
board. This can come either from VIN via an on-board regulator, or be supplied by USB or
another regulated 5V supply.
• 3.3v. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.
• GND.Ground pins. [2][4][9]
Memory
The ATmega2560 has 256 KB of flash memory for storing code (of which 8 KB is used for the
boot loader), 8 KB of SRAM and 4 KB of EEPROM (which can be read and written with the
EEPROM library). [4]
INPUT/OUT
Each of the 54 digital pins on the Mega can be used as an input or output, using pinMode(),
digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or
receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of
20-50 kΩ. In addition, some pins have specialized functions:
Serial: 0 (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX) and 16 (TX);
Serial 3: 15 (RX) and 14 (TX). Used to receive (RX) and transmit (TX) TTL serial data.
Pins 0 and 1 are also connected to the corresponding pins of the ATmega8U2 USB-to-
TTL Serial chip.
External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19 (interrupt 4), 20
(interrupt 3), and 21 (interrupt 2).These pins can be configured to trigger an interrupt on a
low value, a rising or falling edge, or a change in value.
PWM: 0 to 13.Provide 8-bit PWM output with the analogWrite () function.
SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). These pins support SPI communication,
which, although provided by the underlying hardware, is not currently included in the
Arduino language.
LED: 13.There is a built-in LED connected to digital pin 13. When the pin is HIGH
value, the LED is on, when the pin is LOW, it's off.
I2C: 20 (SDA) and 21 (SCL).Support I2C (TWI) communication using the Wire library
(documentation on the Wiring website). Note that these pins are not in the same location
as the I2C pins on the Duemilanove.
The Mega2560 has 16 analog inputs, each of which provides 10 bits of resolution. By default
they measure from ground to 5 volts, though is it possible to change the upper end of their range
using the AREF pin and analog Reference () function.
There are a couple of other pins on the board:
• AREF. Reference voltage for the analog inputs. Used with analogReference().
• Reset. Bring this line LOW to reset the microcontroller. Typically it used to add a reset button
to shields which block the one on the board. [2][4][9]
Feature Specification
Microcontroller ATmega2560 ATmega2560
Operating voltage 7-12V
Input voltage (limits) 6-20v
Digital I/O pins 54 (of which 14 provide PWM output)
Analog Input pins 16 port
DC current per I/O pin 40Ma
DC current for 3.3v pin 50mA
Flash Memory 256 KB of which 8 KB used by boot loader
Clock Speed 16MHz
SRAM 8 KB
EEPROM 4 KB
(2) The Module automatically sends eight 40 kHz and detect whether there is a pulse signal
back.
(3) IF the signal back, through high level , time of high output IO duration is the time from
sending ultrasonic to returning. Test distance = (high level time × velocity of sound (340M/S) /
2. [4][6]
Test distance = (high level time * ultrasonic spreading velocity in air) / 2, you can calculate the
distance to the obstacle. [4]
HC-SR04
Echo Receive pin
Timing diagram
The Timing diagram is shown below. You only need to supply a short 10uS pulse to the trigger
input to start the ranging, and then the module will send out an 8 cycle burst of ultrasound at 40
kHz and raise its echo. The Echo is a distance object that is pulse width and the range in
proportion .You can calculate the range through the time interval between sending trigger signal
and receiving echo signal. Formula: uS / 58 = centimeters or uS / 148 =inch; or: the range = high
level time * velocity (340M/S) / 2; we suggest to use over 60ms measurement cycle, in order to
prevent trigger signal to the echo signal. [4][6][10]
standard value
Item Symbol condition Unit
min. typ. Max.
VDD = + 5 V 4.7 5.0 5.3
Input Voltage VDD V
VDD = + 3 V 2.7 3.0 5.3
Supply Current IDD VDD = + 5 V - 1.65 - Ma
- 20 °C 5.0 5.1 5.7
Recommended LC
Driving 0 °C 4.6 4.8 5.2
Voltage for Normal VDD to V0 25 °C 4.1 4.5 4.7 V
Temperature 50 °C 3.9 4.2 4.5
Version Module
70 °C 3.7 3.9 4.3
EL Power Supply IEL VEL = 110 - - 5.0 mA
Current VAC, 400 Hz
2.2.5 Buzzer
The buzzer we use in this project is an electromechanical component we can use to make noise. Inside the
buzzer is a coil of wire and a small magnet .when current flows through the coil, it becomes magnetized
and pulls toward the magnet, creating a tiny “click’. When we do these thousands of times per second, we
create tones. The Arduino has a built-in command called tone () which clicks the buzzer at a certain
frequency. [4]
The buzzer has two pins: one is positive and the other is negative, the positive pin connect to the digital
pin of Arduino and the negative pin connect with the ground. [9][4]
CHAPTER THREE
Power supply
LCD Display
Front
sensor
ARDUNIO Buzzer
Left (ATmega2560P)
sensor
Back
Right
sensor sensor
Right side
Back side
Front side
Left side
In these sections, the system component will be designed to operate the car collision avoidance
system properly and the overall idea of the project clarifies by flow chart as follow:
Flow chart
Start
Is distance <0.5m?
YES NO
End
Arduino
Proteus-8 software to build and run our circuit
Arduino
The Arduino development environment contains a text editor for writing code, a message area, a
text console, a toolbar with buttons for common functions, and a series of menus. It connects to
the Arduino hardware to upload programs and communicate with them.
Proteus-8.1 professional
Proteus 8.1 is a single application with many service modules offering different
functionality (schematic capture, PCB layout, etc.).
In the circuit Diagram we use a potentiometer (POT) meter or variable resistance to measures the
distance between the car and the obstacle. When the distance between the car and obstacle large
the conductivity is high and resistivity is low. Depending on this way the ultrasonic sensor
measures Relative distance from the obstacle. The output of POT connects to the test Pin of
ultrasonic sensor. If the relative distance is the desired range, POT sends the signals to the
ultrasonic sensor receiver. The ultrasonic receives signal and sends to the Arduino 2560
microcontroller through trigger pin and echo pin. Arduino receives that signal and calculate the
relative distance then display it on the liquid crystal display (LCD).when the distance less than
the threshold value the Buzzer gives sound and we use transistor to amplify current to the buzzer.
CHAPTER FOUR
In this paper, an effective method is proposed for the collision avoidance system of a car to
detect the obstacle present in front, right left and back side blind spot of the car. The driver is
made alert via a buzzer as the distance between car and obstacle reduces and is displayed on
display board. The ultrasonic sensor detects the state of the object whether it is in farther distance
or near with respect to the car. This system is useful for detecting vehicle, motorcycle, bicycle
and pedestrians that pass by the lateral side of vehicle.
In the proposed work the system is going to be implemented using Arduino board along with
ultrasonic sensor module HC-SR04. The control unit is the main processing unit through which
all the other modules are connected. The ultrasonic sensor is a high range sensor which can
detect the obstacle up to 8 meters. Ultrasonic sensor (module HC-SR04) is implemented in the
front of the car which serves as forward car collision avoidance. The two sensor modules HC -
SR04 are used in such a way that they can detect the obstacle in blind spot of the car right and
left side and the other one is in the back side of the car serves as backward vehicle collision
avoidance. The sensor can detect the distance between the car and the obstacle. The calculated
distance can be displayed on the LCD and a buzzer is blown to alert the driver if the distance
between the obstacle and car crosses the minimum safe distance.
4.2 RECOMMENDATIONS
We have designed a “CAR COLLISION AVOIDANCE SYSTEM USING ARDUINO AND
ULTRASONIC SENSOR “but in our design there are some parts which must be done in future.
These are:
We have used ultrasonic sensor to take the input by detecting the object around the car
and to measure relative distance but this project can be develop a system that can detect
the obstacles by implying image processing methodology and can be able to measure the
distance of the obstacles which are beyond the range of the ultrasonic sensor module to
maximize efficiency of the system.
We have used buzzer to alert the driver when the distance cross the minimum safe
distance. But this project can be modified by applying the brake automatically through
stepper and accelerate or decelerate the car according to the relative distance.
The project can be modified by implanting ultrasonic sensor for detection purpose of
real time moving object and calculate the speed of the object
Reference
Books
[1] Automobile blind-spot monitoring system, tri-city insurance news, January 27, 2016
[2] Greenfield, J. (2000). Digital Design using Integrated Circuits
[3] G. Benet, F. Blanes, J.E. Simó, P. Pérez, “Using Infrared Sensors for Distance Measurement
in Mobile Robots”, ELSEVIER Robotics and Autonomous Systems
Website
[4] https://www.sparkfun.com/ Electronic components with datasheets. Accessed on January25,
2016
APPENDIX
Arduino c code
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int fsignal=A15; int fecho=A14;
int bu=13;
int lsignal=A12; int lecho=A11;
int rsignal=A4; int recho=A6;
int bsignal=A0; int becho=A1;
float ftime=0; float fdistance=0;
float ltime=0; float ldistance=0;
float rtime=0; float rdistance=0;
float btime=0; float bdistance=0;
void setup() {
lcd.begin(16,4);
pinMode(13, OUTPUT);
pinMode(fsignal,OUTPUT);
pinMode(fecho,INPUT);
pinMode(lsignal,OUTPUT);
pinMode(lecho,INPUT);
pinMode(rsignal,OUTPUT);
pinMode(recho,INPUT);
pinMode(bsignal,OUTPUT);
pinMode(becho,INPUT);
}
void loop()
{
digitalWrite(fsignal,LOW);
delayMicroseconds(2);
digitalWrite(fsignal,HIGH);
delayMicroseconds(10);
digitalWrite(fsignal,LOW);
delayMicroseconds(2);
ftime=pulseIn(fecho,HIGH);
fdistance=ftime*340/2000000;
if(fdistance<=1)
{
digitalWrite(bu,HIGH);
}
else {
digitalWrite(bu,LOW);
}
digitalWrite(lsignal,LOW);
delayMicroseconds(2);
digitalWrite(lsignal,HIGH);
delayMicroseconds(10);
digitalWrite(lsignal,LOW);
delayMicroseconds(2);
ltime=pulseIn(lecho,HIGH);
ldistance=ltime*340/2000000;
if(ldistance<=1)
{
digitalWrite(bu,HIGH);
}
else {
digitalWrite(bu,LOW);
}
digitalWrite(rsignal,LOW);
delayMicroseconds(2);
digitalWrite(rsignal,HIGH);
delayMicroseconds(10);
digitalWrite(rsignal,LOW);
delayMicroseconds(2);
rtime=pulseIn(recho,HIGH);
rdistance=rtime*340/2000000;
if(rdistance<=1)
{
digitalWrite(bu,HIGH);
}
else {
digitalWrite(bu,LOW);
}
digitalWrite(bsignal,LOW);
delayMicroseconds(2);
digitalWrite(bsignal,HIGH);
delayMicroseconds(10);
digitalWrite(bsignal,LOW);
delayMicroseconds(2);
btime=pulseIn(becho,HIGH);
bdistance=btime*340/2000000;
if(bdistance<=1)
{
digitalWrite(bu,HIGH);
}
else {
digitalWrite(bu,LOW);
}
lcd.setCursor(0,0);
lcd.print("front= ");
lcd.print(fdistance);
lcd.print("m");
lcd.setCursor(0,1);
lcd.print("left= ");
lcd.print(ldistance);
lcd.print("m");
lcd.setCursor(0,2);
lcd.print("rigth= ");
lcd.print(rdistance);
lcd.print("m");
lcd.setCursor(0,3);
lcd.print("back= ");
lcd.print(bdistance);
lcd.print("m");
delay(100);
}