Professional Documents
Culture Documents
Submitted by Submitted to
Amit Bar 1. Mr. Mayur Dev Sewak
ETCE,UG-III General Manager, Operations
Jadavpur University,Kolkata Eisystems Services
2. Mr. Krishnamohan Pandey
Trainer,ICT Domain,Logicpro Infosystems
Eisystems Services
CONTENTS
SL No. Heading Page No.
1 Notations 3
2 List of Figures 4
3 Abstract 5
4 Objectives 6
5 Project Summery 6
6 Introduction 7
8 Components Required 8
9 A. Hardware Description
9-20
Description of Hardware And Software
B. Software Description 21
1 Application 30
12 Conclusion 31
13 Future Scope 31
14 References 32
Notations
RX : Reciever
TX : Transmitter
Project Summery
Here we will do the simulation part on the tinkercad online platform and also do the practical implementation
with hardwares to make a Distance Measurement System. We will write the program and accordingly we will
make the circuits connections and finally measured distance will be shown on the crystal display . Finally we
will see the various practical field where this project can be used.
1. Introduction
Distance measurement of an object in front or by the side of a moving entity is required in a large number of
devices. These devices may be small or large and also quite simple or complicated. Such distance measurement
systems are available. These use various kinds of sensors and systems. Low cost and accuracy as well as speed is
important in most of the applications. In this paper, we describe such a measurement system which uses
ultrasonic transmitter and receiver units mounted at a small distance between them and microcontroller based
system. This microcontroller is very easily available at low cost. A correlation is applied to minimize the error in
the measured distance. Ultrasound sensors are very versatile in distance measurement. They are also providing
the cheapest solutions. Ultrasound waves are useful for both the air and under-water . Ultrasonic sensors are
also quite fast for most of the common applications. In simpler system a low cost version of 8- bit
microcontroller can also be used in the system to lower the cost.
Power supply
Figure -2.1
3. Components Required
Sl No. Name Specification Quantity Price(Rs.)
Figure-3.1
4. Description of Hardware And Software
A. Hardware Descpription
Introduction
Arduino refers to an open-source electronics platform or board and the software used to program it. An
Arduino board can be purchased preassembled or, because the hardware design is open source, built by hand .
A pre-assembled Arduino board includes a microcontroller, which is programmed using Arduino programming
language and the Arduino development environment. Arduino programming language is a simplified from of
C/C++ programming language based on what Arduino calls "sketches," which use basic programming
structures, variables and functions. These are then converted into a C++ program.
Hardware
Arduino is open-source hardware. Most Arduino boards consist of an Atmel 8-bit
AVR microcontroller (ATmega8, ATmega168, ATmega328, ATmega1280, ATmega2560) with varying amounts of
flash memory, pins, and features. We have arduino with ATmega 328.
ATmega328
The ATmega328 is a single-chip microcontroller created by Atmel in the megaAVR family.
Specification
The Atmel 8-bit AVR RISC-based microcontroller combines 32 kB ISP flash memory with read-while-write
capabilities, 1 kB EEPROM, 2 kB SRAM, 23 general purpose I/O lines, 32 general purpose working registers,
three flexible timer/counters with compare modes, internal and external interrupts, serial programmable
USART, a byte-oriented 2-wire serial interface, SPI serial port, 6-channel 10-bit A/D converter (8-channels
in TQFP and QFN/MLF packages), programmable watchdog timer with internal oscillator, and five software
selectable power saving modes. The device operates between 1.8-5.5 volts. The device achieves throughput
approaching 1 MIPS per MHz.
Key Parameters
Parameter Value
Flash memory 32 Kb
SRAM 2 kB
EEPROM 1 kB
External interrupts 2
USB Interface No
USB Speed –
Microcontroller: ATmega328
Operating Voltage: 5V
Input Voltage (recommended): 7-12V
Input Voltage (limits): 6-20V
Digital I/O Pins: 14 (of which 6 provide PWM output)
Analog Input Pins: 6
DC Current per I/O Pin: 40 mA
DC Current for 3.3V Pin: 50 mA
Flash Memory: 32 KB of which 0.5 KB used by bootloader
SRAM: 2 KB (ATmega328)
EEPROM: 1 KB (ATmega328)
Clock Speed: 16 MHz
Pin diagram
Figure-4.A.1
Figure-4.A.2
Introduction
The HC-SR04 Ultrasonic Distance Sensor is an inexpensive device that is very useful for robotics and test
equipment projects. This tiny sensor is capable of measuring the distance between itself and the nearest solid
object. An ultrasonic sensor is a device that is generally used to measures the distance to an object and object
detection using ultrasonic sound waves. The sensor head transmits an ultrasonic wave and receives the wave
reflected from the object. Ultrasonic Sensors measure the distance to the object by calculating the time
between the transmission and reception.
The HC-SR04 can be hooked directly to an Arduino or other microcontroller and it operates on 5 volts.
This ultrasonic distance sensor is capable of measuring distances between 2 cm to 400 cm. It’s a low current
device so it’s suitable for battery powered devices. This device is widely used in SONAR systems.
Working
Ultrasonic distance sensors use pulses of ultrasonic sound (sound above the range of human hearing) to
detect the distance between them and nearby solid objects. The sensors consist of two main components:
An Ultrasonic Transmitter – This transmits the ultrasonic sound pulses, it operates at 40 KHz
An Ultrasonic Receiver – The receiver listens for the transmitted pulses. If it receives them it produces an
output pulse whose width can be used to determine the distance the pulse travelled.
The HC-SR04 has the following four connections:
VCC – This is the 5 Volt positive power supply.
Trig – This is the “Trigger” pin, the one driven to send the ultrasonic pulses.
Echo – This is the pin that produces a pulse when the reflected signal is received. The length of the pulse is
proportional to the time it took for the transmitted signal to be detected.
GND – This is the Ground pin.
Figure-4.A.3
Figure-4.A.4
i. A 5 volt pulse of at least 10 uS (10 microseconds) in duration is applied to the Trigger pin.
ii. The HC-SR04 responds by transmitting a burst of eight pulses at 40 KHz. This 8-pulse pattern makes
the “ultrasonic signature” from the device unique, allowing the receiver to discriminate between
the transmitted pattern and the ultrasonic background noise.
iii. The eight ultrasonic pulses travel through the air away from the transmitter. Meanwhile the Echo
pin goes high to start forming the beginning of the echo-back signal.
iv. If the pulse in NOT reflected back then the Echo signal will timeout after 38 mS (38 milliseconds)
and return low. This produces a 38 mS pulse that indicates no obstruction within the range of the
sensor.
v. If the pulse IS reflected back the Echo pin goes low when the signal is received. This produces a pulse
whose width varies between 150 uS to 25 mS, depending upon the time it took for the signal to be
received.
vi. The width of the received pulse is used to calculate the distance to the reflected object. Remember
that the pulse indicates the time it took for the signal to be sent out and reflected back so to get
the distance you’ll need to divide your result in half.
Figure-4.A.5
Figure-4.A.6
The illustration below shows the dimensions of the HC-SR04 Ultrasonic Distance Sensor as well as the
effective angle of operation. As you can see the sensor is most accurate when the object to be detected
is directly in front of it but you do get a response from objects within a 45 degree “window”. The
documentation recommends confining that window to 30 degrees (15 degrees on either side) for
accurate readings.
Figure-4.A.7
More details about HC SR04- Click
3. LCD Module
Figure-4.A.8 Top View
The I2C 16×2 Arduino LCD Screen is using an I2C communication interface. It is able to display 16×2 characters
on 2 lines, white characters on blue background.This display overcomes the drawback of LCD 1602 Parallel LCD
Display in which you’ll waste about 8 Pins on your Arduino for the display to get working. Luckily in this product,
an I2C adapter is directly soldered right onto the pins of the display. So all you need to connect are the I2C pins,
which shows a good library and little of coding.
The I2C is a type of serial bus developed by Philips, which uses two bidirectional lines, called SDA (Serial Data
Line) and SCL (Serial Clock Line). Both must be connected via pulled-up resistors. The usage voltages are
standard as 5V and 3.3V.If you already have the I2C adapter soldered onto the board like in this product, the
wiring is quite easy. You should usually have only four pins to hook up. VCC and GND of course. The LCD display
works with 5 Volts. So we go for the 5V Pin.
The values shown on the display can be either a simple text or numerical values read by the sensors, such as
temperature or pressure, or even the number of cycles that the Arduino is performing.
4 pins for the LCD display:
PIN DETAILS:-
1. VCC,
2. GND,
3. SDA,
4. SCL.
It will saves at least 4 digital / analog pins on Arduino. Usually, Arduino LCD display projects will run out of pin
resources easily, especially with Arduino Uno. And it is also very complicated with the wire soldering and
connection.
Basically It is a testing board for electronic circuits. Widely use in colleges,laboratory and may industry related to
electronic products.
Figure -4.A.10
5. Jumper wires
This is a set of 10 rainbow color male to male jumper wires. They can be used for interconnecting electronic
components on breadboard or berg strips. The wires are 20 cm long. Both the side of the wire has male
pins. The color of all four wires will be different but the exact color might vary from that of the
picture. These male to male jumper wires are of good quality, reusable and has an approximate length of 20cm.
Easy to plug in
Durable, Flexible
Multiple Colours
Figure -4.A.11
B. SOFTWARE DESCRIPTION
Arduino IDE
Introduction
Arduino consists of both a physical programmable circuit board (often referred to as a microcontroller) and a
piece of software, or IDE (Integrated Development Environment) that runs on your computer, used to write and
upload computer code to the physical board.
First, the Arduino compiler/IDE accepts C and C++ as-is. In fact many of the libraries are written in C++. Much of
the underlying system is not object oriented, but it could be. Thus, "The arduino language" is C++ or C.
Figure-4.B.1
A. Simulation Project-
First the code is written for this project and then the circuit connection is made accordingly on Tinkercad
online simulation platform.
Methodology-
Simulated Code
*/
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
long duration;
void setup() {
lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of
the display
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
distanceCm= duration*0.034/2;
distanceInch = duration*0.0133/2;
lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print(" cm");
delay(10);
lcd.setCursor(0,1);
lcd.print("Distance: ");
lcd.print(distanceInch);
lcd.print(" inch");
delay(10);
}
Schematic Diagram
Implementation
Now for the simulation part first we take a wire and connect it with 5V pin and connect the other end
to the positive rail of breadboard.
Next we take another wire and connect it to the ‘GND’ pin of Arduino and we connect the other port to
negative rail of the breadboard.
After that we connect ‘Vcc’ and ‘GND’ pin of both ultrasonic sensor and display module to the positive
and negative rail of the breadboard respectively.
Next we connect the trigger pin of ultrasonic sensor to ‘pin 9’ of Arduino board and we connect the
echo pin of ultrasonic sensor pin of ultrasonic sensor to ‘pin 10’ of Arduino board. And hence the
connection of Arduino is completed.
Next we write the code under CODE section on the tinkercad simulator and run it over this platform.
We find the measured distance on the LCD display in cm as well as in inch. .
After Simulation
First the code is written for this project on the Arduino ide and then the circuit connection is made accordingly
on the bread board .Then connect the power cable with arduino and then run the program.
Methodology-
Code written on Arduino IDE
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x3F, 16, 2); // Change to (0x27,16,2) for 16x2 LCD.my address is (0x3F)
long distance;
long distanceInch;
long duration;
void setup(){
lcd.init();
lcd.backlight();
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
lcd.setCursor(0,0);
lcd.setCursor(0,1);
delay(2000);
void loop() {
ULTRASONIC();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("DISTANCE CM:");
lcd.print(distance);
lcd.setCursor(0,1);
lcd.print("DISTANCE INCH:");
lcd.print(distanceInch);
// lcd.setCursor(0,1);
// lcd.print("DISTANCE MM:");
// lcd.print(distanceInch);
}
void ULTRASONIC(){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
distance = duration*0.034/2;
distanceInch = duration*0.0133/2;
Now for the practical hardware part first we take a male to male jumper wire and connect it with 5V pin
and connect the other end to the positive rail of breadboard.
Next we take another male to male jumper wire and connect it to the ‘GND’ pin of Arduino and we
connect the other port to negative rail of the breadboard.
After that we connect ‘Vcc’ and ‘GND’ pin of both ultrasonic sensor and display module to the positive
and negative rail of the breadboard respectively.
Next we connect the trigger pin of ultrasonic sensor to ‘pin A0’ of Arduino board and we connect the
echo pin of ultrasonic sensor pin of ultrasonic sensor to ‘pin A1’ of Arduino board. And hence the
connection of Arduino is completed.
Next we write the code on Arduino IDE and burn it to the Arduino board.
Then we supply power to the Arduino via cable and run the program .
Now we can see the measured distance (on the LCD display ) of the object with respect to the
ultrasonic sensor.
Figure-5.B.2 -- practical system at working
*To See the video (full process of the project) please Click Here .
6. Application
Driverless car
Robotics
In radar
To measure the level of fuel in the aircraft fuel tank
7. Conclusion
The objective of this project was to design and implement an distance measurement sytem(/device) (using
ultrasonic sensor & Arduino). By using the system we can calculate the distance of the object. The following can
be concluded from the above project-:
The system can calculate the distance of the object without errors.
The system provide low cost and efficient solution.
8. Future Scope
We can use humidity sensors in future to measure distance in different environment.
Using ultrasonic sensor with better specification we can increase the distance measurement
range.
This system is used in driverless car to detect obstacle.
This system with some buzzer can be used in navigation System for blind people to detect the
obstacle.
10. References
1. Arduino programming – Richard Bloom