CHND
CHND
CHND
MASTER OF ENGINEERING
In
Submitted by
NARIGA CHANDU
100522744107
2022 - 2024
1
BONAFIDE CERTIFICATE
SIGNATURE
Mr.Md.Misbahuddin
Asst.Prof.
Electronics and Communication Engineering
Osmania University
ii
2
ABSTRACT
The project is designed to develop distance measurement system using ultrasonic
waves and interfaced with arduino. We know that human audible range is 20hz to
20khz. We can utilize these frequency range waves through ultrasonic sensor HC-
SR04.The advantages of this sensor when interfaced with arduino which is a control
and sensing system, a pro per distance measurement can be made with new techniques.
As large amounts are spent for hundreds of inflexible circuit boards, the arduino will
allow business to bring many more unique devices. This distance measurement system
can be widely used as range meters and as proximity detectors in industries. The
obstacle from the sensor is measured through ultrasonic sensor. After knowing the
iii
3
CHAPTER NO. TITLE
PAGE NO
Certificate ii
Abstract iii
1 INTRODUCTION 1
3.1 Conclusion 17
3.2 Future Scope 17
4 Code 18
4
CHAPTER 1
INTRODUCTION
Today’s the developing world shows various adventures in every field. In each field the small
requirements are very essential to develop big calculations. By using different sources we can
modify it as our requirements and implement in various field. In earlier days the measurements
are generally occur through measuring devices. But now a day’s digitalization as is on height.
Therefore we use a proper display unit for measurement of distance. We can use sources such as
sound waves which are known as ultrasonic waves using ultrasonic sensors and convert this sound
wave for the measurement of various units such as distance, speed. This technique of distance
measurement using ultrasonic in air includes continuous pulse echo method, a burst of pulse is
sent for transmission medium and is reflected by an object kept at specific distance. The time taken
for the sound wave to propogate from transmitter to receiver is proportional to the distance of the
object. In this distance measurement system we had ultrasonic sensor HC-SR04 interfaced with
arduino UnoR3. Programming and hardware part of ultrasonic sensor interfacing with arduino
UnoR3.
5
CHAPTER 2
COMPONENTS USED AND THE CIRCUIT DIAGRAM
6
First of all we need to trigger the ultrasonic sensor module to transmit signal by using arduino and
then wait for receive ECHO. Arduino reads the time between triggering and Received ECHO. We
know that speed of sound is around 340m/s. so we can calculate distance by using given formula:
The Arduino Uno has a total of 14 digital input/output pins, 6 of which can be used as PWM
outputs and 6 analog inputs. It also has a 16 MHz quartz crystal oscillator and a power-saving
sleep mode that allows the board to consume minimal power when idle. It has 14 digital
input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic
7
resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an ICSP header and a reset
button. It contains everything needed to support the microcontroller.
One of the key features of the Arduino Uno is its open-source nature. This means that
anyone can access the source code and make changes to it, or use it for their projects. The
Arduino platform also comes with a large community of users who share their projects and offer
support to others. There are also a large number of libraries available for the Arduino platform,
which makes it easy to add functionality to projects without having to write complex code.
Programming
The programming of the Arduino UNO is accomplished using the Arduino Software
Integrated Development Environment (IDE). To select the appropriate microcontroller board,
the user must choose "Arduino UNO" from the Tools > Board menu. The ATmega328
microcontroller on the Arduino UNO is pre-equipped with a bootloader, which enables the user
to upload new code to the device without the need for an external hardware programmer.
Power
The Arduino UNO can be powered through either a USB connection or an external
power source, with the source being selected automatically. External power can be provided by
an AC-to-DC adapter or battery, with the adapter connected to the board's power jack and the
battery connected to the GND and Vin pin headers of the POWER connector. The board
operates optimally with an external power supply of 7 to 12 volts, but can range from 6 to 20
volts. If the voltage is less than 7V, the 5V pin may not provide a stable output and if the voltage
is greater than 12V, the voltage regulator may overheat, potentially damaging the board.
• 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 - This pin outputs a regulated 5V from the regulator on the board. The board can be
supplied with power either from the DC power jack (7 - 12V), the USB connector (5V),
8
or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses
the regulator, and can damage your board. We don't advise it.
• 3.3V - A 3.3 volt supply generated by the on-board regulator. Maximum current draw
is 50 mA.
• GND - Ground pins.
• IOREF - This pin on the Arduino board provides the voltage reference with which the
microcontroller operates. A properly configured shield can read the IOREF pin voltage
and select the appropriate power source or enable voltage translators on the outputs to
work with the 5V or 3.3V.
Memory
The ATmega328 has 32 KB (with 0.5 KB occupied by the bootloader). It also has 2 KB
of SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).
The UNO board has 14 digital pins that can function as inputs or outputs using the
functions pinMode(), digitalWrite(), and digitalRead(). These pins operate at 5V and have a
recommended operating current of 20mA. Each pin also has an internal pull-up resistor
(disconnected by default) of 20-50k ohms. To avoid damage to the microcontroller, the
maximum current allowed on any I/O pin must not exceed 40 mA.
In addition, some pins have specialized functions:
• Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data.
These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL
Serial chip.
• External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a
low value, a rising or falling edge, or a change in value. See the attachInterrupt()
function for details.
• PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
• SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication
using the SPI library.
• LED: 13. There is a built-in LED driven by digital pin 13. When the pin is HIGH value,
the LED is on, when the pin is LOW, it's off.
9
• TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire
library.
The UNO has 6 analog inputs, labelled A0 through A5, each of which provides 10 bits of
resolution (i.e. 1024 different values). 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 the
analogReference() function.
• AREF. Reference voltage for the analog inputs. Used with analogReference().
• Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset
button to shields which block the one on the board.
Communication
The Arduino UNO has multiple communication options with computers, other boards,
or microcontrollers. It has a UART TTL serial communication feature through digital pins 0
(RX) and 1 (TX), which is converted to USB communication by the ATmega16U2 on the board
and appears as a virtual COM port to the computer. The Arduino IDE comes with a serial
monitor for sending and receiving simple text data. The RX and TX LEDs on the board flash
when data is transmitted via USB and the computer, but not when communicating through pins
0 and 1.
Technical Specifications
Microcontroller ATmega328P
Operating Voltage 5V
10
DC Current per I/O Pin 20 mA
SRAM 2 KB (ATmega328P)
EEPROM 1 KB (ATmega328P)
LED_BUILTIN 13
Length 68.6 mm
Width 53.4 mm
Weight 25 g
ULTRASONIC SENSOR-SR04
It emits an ultrasound at 40 000 Hz which travels through the air and if there is an object or
obstacle on its path It will bounce back to the module. Considering the travel time and the speed
of the sound you can calculate the distance.
HC-SR04
11
One of the most popular ultrasonic sensors would be the HC-SR04. The configuration pin of
HC-SR04 is VCC (1), TRIG (2), ECHO (3), and GND (4). The supply voltage of VCC is 5V and
you attach TRIG and ECHO pin to any Digital I/O in your Arduino Board to power it.
Specifications
• Power Supply: DC 5V
• Working Current: 15mA
• Working Frequency: 40Hz
• Ranging Distance : 2cm – 400cm/4m
• Resolution : 0.3 cm
• Measuring Angle: 15 degree
• Trigger Input Pulse width: 10uS
• Dimension: 45mm x 20mm x 15mm
Next up we have our very own Grove – Ultrasonic Distance Sensor, Seeed’s very own version of
an ultrasonic distance sensor which is comparative to the HC-SR04.
It can measure from 3cm to 350cm with the accuracy up to 2mm. It is a perfect
ultrasonic module for distance measurement, proximity sensors, and ultrasonic detector.
Specifications
12
• Measuring Angle: 15 degree
• Trigger Input Pulse width: 10uS TTL
• Dimension: 50mm x 25mm x 16mm
Working Voltage
• Transmitting and receiving signals on the Grove-Ultrasonic Distance Sensor share one
pin, saving the requirement of using all available pins
Potentiometer
13
10K Potentiometer
Potentiometer Pin Diagram
1 Fixed End This end is connected to one end of the resistive track
2 Variable End This end is connected to the wiper, to provide variable voltage
3 Fixed End This end is connected to another end of the resistive track
Features
14
Alternative Variable Resistor
Selecting a Potentiometer
Potentiometers also known as POT, are nothing but variable resistors. They can provide a
variable resistance by simply varying the knob on top of its head. It can be classified based on two
main parameters. One is their Resistance (R-ohms) itself and the other is its Power (P-
Watts) rating.
The value or resistance decides how much opposition it provides to the flow of current. The greater
the resistor value the smaller the current will flow. Some standard values for a potentiometer are
500Ω, 1K, 2K, 5K, 10K, 22K, 47K, 50K, 100K, 220K, 470K, 500K, 1 M.
Resistors are also classified based on how much current it can allow; this is called Power (wattage)
rating. The higher the power rating the bigger the resistor gets and it can also more current. For
potentiometers the power rating is 0.3W and hence can be used only for low current circuits.
As far as we know resistors should always have two terminals but, why a potentiometer has three
terminals and how to we use these terminals. It is very easy to understand the purpose of these
terminals by looking at the diagram below.
The diagram shows the parts present inside a potentiometer. We have a resistive track whose
complete resistance will be equal to the rated resistance value of the POT.
As the symbol suggests a potentiometer is nothing but a resistor with one variable end. Let us
assume a 10k potentiometer, here if we measure the resistance between terminal 1 and terminal 3
we will get a value of 10k because both the terminals are fixed ends of the potentiometer. Now,
15
let us place the wiper exactly at 25% from terminal 1 as shown above and if we measure the
resistance between 1 and 2 we will get 25% of 10k which is 2.5K and measuring across terminal
2 and 3 will give a resistance of 7.5K.
So the terminals 1 and 2 or terminals 2 and 3 can be used to obtain the variable resistance and the
knob can be used to vary the resistance and set the required value.
Applications
16
16x2 LCD Module
17
16x2 LCD modules are very commonly used in most embedded projects, the reason being
its cheap price, availability, programmer friendly and available educational resources.
2 Vdd (+5 Volt) Powers the LCD with +5V (4.7V – 5.3V)
5 Read/Write Used to read or write data. Normally grounded to write data to LCD
7 Data Pin 0 Data pins 0 to 7 forms a 8-bit data line. They can be connected to
Microcontroller to send 8-bit data.
These LCD’s can also operate on 4-bit mode in such case Data pin
4,5,6 and 7 will be left free.
8 Data Pin 1
18
9 Data Pin 2
10 Data Pin 3
11 Data Pin 4
12 Data Pin 5
13 Data Pin 6
14 Data Pin 7
19
16x2 LCD Display Equivalents
16×2 LCD is named so because; it has 16 Columns and 2 Rows. There are a lot of combinations
available like, 8×1, 8×2, 10×2, 16×1, etc. but the most used one is the 16×2 LCD. So, it will have
(16×2=32) 32 characters in total and each character will be made of 5×8 Pixel Dots. A Single
character with all its Pixels is shown in the below picture.
Now, we know that each character has (5×8=40) 40 Pixels and for 32 Characters we will have
(32×40) 1280 Pixels. Further, the LCD should also be instructed about the Position of the Pixels.
Hence it will be a hectic task to handle everything with the help of MCU, hence an Interface IC
like HD44780 is used, which is mounted on the backside of the LCD Module itself. The function
of this IC is to get the Commands and Data from the MCU and process them to display
meaningful information onto our LCD Screen. You can learn how to interface an LCD using the
above mentioned links. If you are an advanced programmer and would like to create your own
library for interfacing your Microcontroller with this LCD module then you have to understand
the HD44780 IC working and commands which can be found its datasheet.
20
CHAPTER 3
CONCLUSION AND FUTURE SCOPE
3.1 Conclusion:
Distance measurement using ultrasonic sensor and arduino consist of a transmitter part
of ultrasonic module units ultrasonic high frequency waves in the form of polices after
collision of these wares with any object, these wares detected by microphone time
taken by these wares from transmitter and receiver is used to measure distance from
any object. We had used a ultrasonic sensor module of HC-SR04, because this
ultrasonic module is initiated with pulse of 10us The distance from any object is
calculated from.
Distance =speed*time
The human audible range can be converted measure the distance precisely manner.
FUTURE SCOPE
i. New prototyping hardware & capatibility & interfacing with other consumer
elatrone/tv/smartphones & flooding of shields.
ii. Mining equepments may require where entail.
iii. Acready compatible with many major simulation software like MATLAB & lab view, we
may see even move flexible programming environment & development option
iv. Using temp. Compensation, it can be used over wide temp range.
v. Height meausrment, agriculture velide, collision /protection can be other application.
21
Code :
#include <LiquidCrystal.h> // includes the LiquidCrystal Library
LiquidCrystal lcd(1, 2, 3, 4, 5, 6); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
const int trigPin = 8;
const int echoPin = 9;
long duration;
int distanceCm, distanceInch;
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);
duration = pulseIn(echoPin, HIGH);
distanceCm= duration*0.034/2;
distanceInch = duration * 0.01330 / 2;
lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("Distance: "); // Prints string "Distance" on the LCD
lcd.print(distanceCm); // Prints the distance value from the sensor
lcd.print(" cm");
delay(10);
lcd.setCursor(0,1);
lcd.print("Distance: ");
lcd.print(distanceInch);
lcd.print(" inch");
delay(10);
}
22