SHRI VAISHNAV VIDYAPEETH VISHWAVIDYALAYA
Department - COMPUTER SCIENCE & ENGINEERING
Session: July-Dec-2024
B.Tech. CSE
IOT PROJECT REPORT
Distance measurement using Ultrasonic sensor and Arduino
Team Members :
Shivam Shah -22100BTCSE11771
Roshan Choudhary - 22100BTCSE11737
Saad Khan - 22100BTCSE1143
Sarwar Ali - 22100BTCSE11760
Shokat Khan - 22100BTCSE11776
Rajvardhan Singh Tomar - 22100BTCSE11714
Samya Sharma - 22100BTCSE11753
Rudrapratap Singh Rajawat - 22100BTCSE1141
PROJECT REPORT
Project - The Arduino-Based Distance measurement System is an innovative project
that replicatesthe functionality of traditional radar systems for object detection. Using
an ultrasonic sensor , this system scans its surroundings, detects objects, and measures
their distance.
Project Discription - The Distance measurement System is a simple yet project
that combines hardware and software to detect and measure the distance ofobjects in real
time. By utilizing ultrasonic sound waves, this systemmimics the working of actual radar
technology
Components
The project is built using the following components:
Arduino Nano: The central micro controller that processes sensor data and controls the
system.
Ultrasonic Sensor (HC-SR04): Measures the distance of objects by emitting sound
waves and detecting echoes.
Breadboard: Simplifies wiring and connections between components.
Connecting Wires: Transmit signals between components and the
Arduino.
Arduino Nano:
The Arduino Nano is Arduino's classic breadboard friendly designed board with the
smallest dimensions. The Arduino Nano comes with pin headers that allow for an easy
attachment onto a breadboard and features a Mini-B USB connector.
The Arduino Nano is a widely used micro-controller development board designed to
make learning and prototyping with electronics easier and more accessible. It's part of
the Arduino platform, an open-source electronics ecosystem that allows users to create
interactive projects and devices.
Ultrasonic Sensor:
An ultrasonic sensor is an electronic device that uses ultrasonic waves (sound waves at
frequencies-higher than the human hearing range) to measure the distance between the
sensor and an object.These sensors are widely used in applications such as distance
measurement, object detection, and level sensing in a variety of industries including
robotics, automotive, and industrial automation.
Working of an Ultrasonic Sensor
An ultrasonic sensor works by emitting ultrasonic sound waves and measuring the time
it takes for those waves to reflect back after hitting an object. Based on the time it takes
for the sound to travel to the object and return, the sensor calculates the distance to the
object.
Breadboard: A breadboard is a versatile and essential tool used in electronics for
prototyping circuits without the need for soldering. It allows you to quickly and easily
build and test electrical circuits by inserting components into a grid of interconnected
holes. Breadboards are commonly used by engineers, hobbyists, and students to create
temporary circuits for testing, learning, and experimenting with electronics.
Jumper Wires:
Jumper wires are flexible electrical wires used to create temporary connections between
different components in an electronic circuit. They are commonly used in prototyping,
especially when working with breadboards, micro controllers (like Arduino), and
various electronic components. Jumper wires come with connectors on both ends, which
can either be male or female, depending on the type of connection required.
Working Mechanism -
The ultrasonic sensor sends out a high-frequency sound wave that travels until it hits an
object.
The sensor detects the time taken for the echo to return and calculates
the distance using the formula: Distance (cm)=Time (µs)58\text{Distance
(cm)} = \frac{\text{Time (µs)}}{58}Distance (cm)=58Time (µs)
The Arduino processes the sensor data and sends it to a Processing
application for visualization.
Code -
#define echoPin \
2 // attach pin D2 Arduino to pin Echo of HC-SR04
#define trigPin \
3 // attach pin D3 Arduino to pin Trig of HC-SR04 \
long duration; // Variable to store time taken to the pulse
// to reach receiver
int distance; // Variable to store distance calculated using
// formula
void setup()
{
pinMode(trigPin,
OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
// Serial Communication is starting with 9600 of
// baudrate speed
Serial.begin(9600);
// The text to be printed in serial monitor
Serial.println(
"Distance measurement using Arduino Uno.");
delay(500);
}
void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2); // wait for 2 ms to avoid
// collision in serial monitor
digitalWrite(
trigPin,
HIGH); // turn on the Trigger to generate pulse
delayMicroseconds(
10); // keep the trigger "ON" for 10 ms to generate
// pulse for 10 ms.
digitalWrite(trigPin,
LOW); // Turn off the pulse trigger to stop
// pulse generation
// If pulse reached the receiver echoPin
// become high Then pulseIn() returns the
// time taken by the pulse to reach the
// receiver
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.0344 / 2; // Expression to calculate
// distance using time
Serial.print("Distance: ");
Serial.print(
distance); // Print the output in serial monitor
Serial.println(" cm");
delay(100);}