Ultrasonic Sensor with Arduino
Ultrasonic Sensor with Arduino
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.
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);
void loop() {
// Trigger ultrasonic sensor
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);