Course Content
πŸ“˜ MODULE 11 – Edge Avoiding Robot
πŸ“¦ MODULE 12 – Smart Multi-Function Robot (Mega Project)
Arduino Hands-On Programming and Robotics Course

πŸ“˜ MODULE 5 – Ultrasonic Distance Meter

This module is practical, so lessons should be focused on concepts, circuit, coding, testing, and troubleshooting rather than very long theory.


πŸ“˜ Lesson 5.1 – What is Ultrasonic Sensor?

🎯 Learning Objectives

After completing this lesson, students will be able to:

βœ… Understand what an Ultrasonic Sensor is

βœ… Understand how distance measurement works

βœ… Identify HC-SR04 sensor pins

βœ… Understand Trigger and Echo pins

βœ… Understand real-world applications of ultrasonic sensors

βœ… Prepare for building an Ultrasonic Distance Meter project


1. Introduction

Have you ever wondered how a robot detects obstacles without touching them?

How does a car know when it is close to a wall while parking?

How do automatic water tank monitoring systems measure water levels?

The answer is often:

Ultrasonic Sensors

Ultrasonic sensors can measure distance without physically touching an object.

This makes them very useful in robotics, automation, and IoT projects.


2. What is an Ultrasonic Sensor?

An ultrasonic sensor is an electronic device that measures distance using sound waves.

Instead of using light, it uses:

Ultrasonic Sound Waves

These sound waves travel through the air, hit an object, and return to the sensor.

The sensor calculates the distance based on the time taken for the sound wave to return.


3. What Does “Ultrasonic” Mean?

Humans can hear sounds between:

20 Hz to 20,000 Hz

Sounds above:

20,000 Hz

are called:

Ultrasonic Sounds

These sounds cannot be heard by humans.

The HC-SR04 sensor operates at approximately:

40 kHz

which is well above human hearing range.


4. Working Principle of Ultrasonic Sensor

The sensor works using the principle of:

Echo

Example:

If you shout in a valley:

Β 
Hello!
Β 

The sound reflects back.

This reflected sound is called an:

Echo

Ultrasonic sensors use the same principle.


5. How HC-SR04 Measures Distance

Step 1

Arduino sends a signal to the Trigger pin.

↓

Step 2

Sensor emits ultrasonic waves.

↓

Step 3

Waves travel through air.

↓

Step 4

Waves hit an object.

↓

Step 5

Waves reflect back.

↓

Step 6

Echo pin sends timing information to Arduino.

↓

Step 7

Arduino calculates distance.


6. HC-SR04 Ultrasonic Sensor

The HC-SR04 is the most commonly used ultrasonic sensor in Arduino projects.

Advantages:

βœ… Low Cost

βœ… Easy to Use

βœ… Accurate

βœ… Beginner Friendly

βœ… Large Community Support


7. HC-SR04 Pin Description

The sensor has four pins:

Pin Function
VCC Power Supply (5V)
TRIG Trigger Signal Input
ECHO Echo Signal Output
GND Ground

VCC

Provides power to the sensor.

Connect to:

Β 
5V
Β 

on Arduino.


GND

Ground connection.

Connect to:

Β 
GND
Β 

on Arduino.


TRIG Pin

Used to start distance measurement.

Arduino sends a short pulse to this pin.


ECHO Pin

Returns the reflected signal timing.

Arduino measures this time to calculate distance.


8. Detection Range

Typical HC-SR04 Specifications:

Parameter Value
Operating Voltage 5V
Frequency 40 kHz
Minimum Range 2 cm
Maximum Range 400 cm
Accuracy Β±3 mm

9. Real-World Applications

Ultrasonic sensors are widely used in:

Distance Measurement

Measuring object distance.


Obstacle Avoiding Robots

Detecting obstacles.


Smart Parking Systems

Vehicle parking assistance.


Water Level Monitoring

Measuring tank levels.


Industrial Automation

Object detection systems.


Security Systems

Motion and object detection.


10. Advantages of Ultrasonic Sensors

Contactless Measurement

No physical contact required.


Good Accuracy

Provides reliable readings.


Low Cost

Affordable for students.


Easy Interfacing

Only four pins.


11. Limitations

Ultrasonic sensors may struggle with:

Soft Surfaces

Sound may be absorbed.


Very Small Objects

Detection becomes difficult.


Irregular Shapes

Echo may scatter.


Heavy Wind Environments

Can affect accuracy.


12. Common Beginner Mistakes

Mistake 1

Connecting VCC and GND incorrectly.


Mistake 2

Mixing Trigger and Echo pins.


Mistake 3

Expecting accurate readings beyond 4 meters.


Mistake 4

Blocking the sensor with hands during testing.


13. Best Practices

βœ… Use stable 5V supply

βœ… Keep sensor facing object directly

βœ… Avoid excessive vibration

βœ… Test at multiple distances

βœ… Use proper wiring


πŸ“Š Summary

In this lesson, we learned:

βœ… What an Ultrasonic Sensor is

βœ… How HC-SR04 works

βœ… Echo principle

βœ… Sensor pins

βœ… Distance measurement concept

βœ… Applications and limitations

The HC-SR04 ultrasonic sensor is one of the most useful sensors in Arduino robotics and automation because it can measure distance accurately without touching the object.


🎯 Quiz

1. What type of waves does HC-SR04 use?

A. Light Waves

B. Radio Waves

C. Ultrasonic Sound Waves βœ…

D. Infrared Waves


2. Which pin starts measurement?

A. VCC

B. GND

C. TRIG βœ…

D. ECHO


3. Which pin returns timing information?

A. TRIG

B. ECHO βœ…

C. VCC

D. GND


4. What is the maximum typical range of HC-SR04?

A. 50 cm

B. 100 cm

C. 400 cm βœ…

D. 1000 cm


5. What principle does the sensor use?

A. Reflection of Sound (Echo) βœ…

B. Magnetism

C. Heat Detection

D. Light Reflection


🏠 Assignment

Task 1

Label all four pins of the HC-SR04 sensor.

Task 2

Draw the working principle diagram of an ultrasonic sensor.

Task 3

List five real-world applications of ultrasonic sensors.

Task 4

Research the specifications of HC-SR04 and create a summary table.

Task 5

Explain the difference between ultrasonic sensing and IR sensing.

Scroll to Top