Project Report: Object Detection using Arduino Uno and Ultrasonic Sensor
1. Introduction
Embedded systems play a vital role in modern electronic design, especially for tasks requiring automation,
control, and real-time responses. This project demonstrates a basic object detection system using Arduino
Uno and an ultrasonic sensor. The objective is to measure the distance of an object using the HC-SR04
sensor and trigger visual/audible alerts when the object is detected within a predefined range.
2. Objectives
- Design and implement an embedded system for object detection
- Interface an HC-SR04 ultrasonic sensor with Arduino Uno
- Trigger LED/Buzzer alert based on object proximity
- Learn basic principles of ultrasonic ranging and embedded programming
3. Components Required
1. Arduino Uno - 1 unit
2. HC-SR04 Ultrasonic Sensor - 1 unit
3. Breadboard - 1 unit
4. Jumper wires - As required
5. LED - 1 unit
6. 220-ohm Resistor - 1 unit
7. Buzzer (optional) - 1 unit
8. USB Cable for Arduino - 1 unit
4. Working Principle
The HC-SR04 sensor uses sonar to determine the distance to an object. It emits an ultrasonic wave through
Project Report: Object Detection using Arduino Uno and Ultrasonic Sensor
the trig pin, and measures the time taken for the echo to return via the echo pin. The formula used is:
Distance = (Time x Speed of Sound) / 2
Speed of sound = 343 m/s. Time is measured in microseconds and converted accordingly.
5. Circuit Diagram
Connections:
- VCC of HC-SR04 -> 5V on Arduino
- GND -> GND
- Trig -> Digital Pin 9
- Echo -> Digital Pin 10
- LED -> Digital Pin 12 (with 220-ohm resistor)
- Buzzer -> Digital Pin 11 (optional)
6. Arduino Code
const int trigPin = 9;
const int echoPin = 10;
const int ledPin = 12;
const int buzzerPin = 11;
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
Project Report: Object Detection using Arduino Uno and Ultrasonic Sensor
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
if (distance < 10) {
digitalWrite(ledPin, HIGH);
digitalWrite(buzzerPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
}
delay(500);
}
7. Applications
- Robotics for obstacle avoidance
- Automotive parking systems
- Industrial automation
- Smart homes for motion detection
8. Conclusion
The project successfully demonstrates a basic object detection system using an Arduino and ultrasonic
sensor. This system can be used as a foundational block for more complex automation systems.
9. Future Scope
- Integrate LCD/OLED displays to show distance values
- Use IoT modules (ESP8266/NodeMCU) for wireless monitoring
- Include servo motors for directional scanning
- Expand to multi-sensor systems for 360° coverage
Project Report: Object Detection using Arduino Uno and Ultrasonic Sensor
10. References
- Arduino Official Documentation: https://www.arduino.cc
- HC-SR04 Datasheet
- Embedded System Design textbook resources