Lab No 14
Measurement of distance using Ultrasonic Sensor with Arduino
Objective:
The objective of a lab involving Ultrasonic sensor is to enable students to understand the
principles and applications of ultrasonic sensing technology. In an ultrasonic sensor, we should
learn the principles of ultrasonics, including sensor calibration and practical applications such as
distance measurement and obstacle detection in real-world scenarios.
Apparatus:
Computer or Laptop
Arduino UNO
Ultrasonic Sensor
LED (Light Emitting Diode)
Prototyping Board (Breadboard)
Ultrasonic Sensor:
An ultrasonic sensor is a device that uses ultrasonic waves for distance measurement and object
detection. It typically consists of a transducer that serves as both a transmitter and a receiver. The
sensor emits high-frequency ultrasonic waves, which travel through the air and bounce back
when they encounter an object. By measuring the time it takes for the waves to return, the sensor
calculates the distance to the object using the speed of sound in the air. Ultrasonic sensors are
widely used in applications such as robotics, industrial automation, and automotive systems for
tasks like obstacle avoidance and proximity sensing.
Fig 14.1
There are various types of ultrasonic sensors designed for specific applications:
1. Ultrasonic Proximity Sensors:
Detect nearby objects without contact, commonly used in robotics for obstacle avoidance.
2. Ultrasonic Distance Sensors:
Measure precise distances by calculating the time taken for ultrasonic waves to return after
hitting an object.
3. Ultrasonic Level Sensors:
Monitor liquid or solid levels by analyzing ultrasonic wave reflections off surfaces, applied in
industries like tank level measurement.
4. Ultrasonic Flow Sensors:
Measure fluid flow by analyzing the time it takes for ultrasonic waves to travel with and against
the flow.
5. Ultrasonic Range Finders:
Determine distances accurately, commonly employed in applications requiring precise range
measurements.
6. Ultrasonic Parking Sensors:
Aid in vehicle parking by detecting obstacles through ultrasonic waves, providing proximity
alerts to drivers.
7. Ultrasonic Gesture Recognition Sensors:
Recognize hand gestures using ultrasonic technology, applied in human-machine interface
applications.
8. Ultrasonic Imaging Sensors:
Generate images in medical applications by analyzing ultrasonic wave reflections in different
tissues.
9. Ultrasonic Cleaning Sensors:
Create ultrasonic waves for cleaning surfaces by removing dirt or particles.
10. Ultrasonic Occupancy Sensors:
Detect human presence by analyzing ultrasonic wave reflections in building automation systems
These specialized types highlight the versatility of ultrasonic sensors across industries,
addressing diverse needs from object detection to medical imaging.
Circuit Diagram:
Circuit Diagram of Ultrasonic Sensor with Arduino
Procedure:
1. First of all, take the circuit diagram.
2. Make the connection according to the circuit diagram.
3. Connect Arduino with Laptop or Computer to upload program in Arduino.
4. Once, program uploading is done.
5. Connect ultrasonic Sensor as well as LED’s with Arduino.
6. Monitor ultrasonic Sensor on Serial Monitor on Arduino Software.
7. Check the output according to ultrasonic Sensor.
8. Show the result to your instructor
Program code:
const int trigPin = 9; // Trigger pin
const int echoPin = 10; // Echo pin
int distance;
void setup() {
// Define pin modes
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
// Start Serial communication
Serial.begin(9600);
}
void loop() {
// Trigger ultrasonic sensor
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Measure the duration of the echo pulse
duration = pulseIn(echoPin, HIGH);
// Calculate distance in centimeters
distance = duration * 0.034 / 2;
// Print the distance to the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// Wait for a short delay before the next measurement
delay(500);
}
Hardware result:
Observation of Ultrasonic sensor with Arduino
Conclusion:
In conclusion, the ultrasonic sensor lab equipped students with a comprehensive understanding
of sensor principles and practical applications. The hands-on experience with Arduino and the
provided circuit facilitated a seamless integration of theory into practice.