กลับไปหน้ารวมไฟล์
basic-setup-for-ultrasonic-sensor-and-arduino-67ab93-en.md

Connections

The Connections can be made direct between Ultrasonic sensor and Arduino (or) You can also use Breadboard to achieve the same.

  • Connect the Vcc pin of Ultrasonic sensor to 5V on Arduino
  • Connect the GND pin of Ultrasonic sensor to GND on Arduino
  • Connect the Trig Pin of Ultrasonic sensor to D6 on Arduino
  • Connect the Echo Pin of Ultrasonic sensor to D5 on Arduino

That's it...

Ultrasonic sensor with Arduino - Circuit Connection using Breadboard

Working

Ultrasonic sensor has wide variety of applications such as distance measurement, object detection, obstacle avoidance etc.,

This project is designed keeping in mind the people who are looking for basic setup of Ultrasonic sensor with Arduino. Any type of Arduino can be used for this project.

The working is very Simple, when the connections are done as per the circuit diagram and when it is powered ON, the Ultrasonic sensor sends sound waves. When the waves come in contact with an object, they bounce back to the sensor. Hence, the distance is calculated by multiplying speed with time. The speed here refers to the speed of sound, which is 340 meters per second. In cm per microseconds it is 0.034 and inch per microseconds it is 0.0133858. We have to divide the speed by 2, since sound wave travels forward and returns back after hitting the object.

On the other hand, the time is the duration taken by the sound wave to travel forward and bounce back. Therefore the distance of object from the Ultrasonic sensor is easily identified.

You can find the calculation in the code attached below. Peace

Technical Implementation: Sensors and Pulse Timing

The project reveals the hidden layers of simple distance-to-data interaction:

  • Identification layer: The Ultrasonic Sensor (HC-SR04) acts as the acoustic eye of your project, measuring distance by emitting high-frequency sound pulses and listening for the echo.
  • Conversion layer: The Arduino uses the Speed of Sound (approximately 340 m/s) to convert the raw "Echo Travel Time" (microseconds) into a precise distance value in centimeters (cm) or inches.
  • Processing Logic layer: The Arduino code follows a specialized "sequential ping" strategy: it triggers the Trigger pin for 10µs and then waits for the Echo pin to return a pulse.
  • Execution layer: Using the pulseIn() function, the Arduino calculates the distance and sends it rhythmically to the Serial Monitor for your observation.

Hardware Infrastructure

  • Arduino Uno: The "brain" of the project, managing the ultrasonic pulses and coordinating the conversion and indicator tasks.
  • Ultrasonic Sensor (HC-SR04): Providing contactless and reliable distance monitoring for each of your measurements.
  • Breadboard: A convenient way to prototype the distance circuit and connect all components without soldering.
  • Micro-USB Cable: Used to program the Arduino directly from your computer for power and data.

Measurement and Interaction Step-by-Step

The ultrasonic distance monitoring process is designed to be very efficient:

  1. Initialize Hardware: Correctly seat the ultrasonic sensor on your breadboard following the provided diagram.
  2. Setup Output Sync: In the setup() function, initialize both the trigger and echo pins, as well as the serial communication at 9600 bps.
  3. Execution Loop: The Arduino constantly performs several high-performance sensor reads and updates the Serial Monitor in real-time.
  4. Visual Feedback: Watch as your distance readings update on the screen.

Output seen in Serial Monitor

Future Expansion

  • OLED Display Integration: Add a small OLED display to show a "Distance Status" (Far/Medium/Near).
  • Multi-sensor Synchronization: Connect several more ultrasonic sensors to independently monitor different directions for a robot or project.
  • Cloud Interface Support: Add a specialized mobile app to precisely control and track your distance data from your smartphone over Bluetooth.
  • Advanced Range Customization: Add a small slider or potentiometer to manually adjust the detection range for a proximity indicator.

Basic Setup for Ultrasonic Sensor and Arduino is a perfect project for any science enthusiast looking for a more interactive and engaging measurement tool!

End Result

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
author: "shassandanish1"
category: "Sensors & Environment"
components:
  - "1x Arduino UNO"
  - "1x Ultrasonic Sensor (HC-SR04)"
  - "1x 5mm LED: Green (for indication)"
  - "1x Resistor 220 ohm"
  - "1x Breadboard (generic)"
  - "10x Jumper wires (generic)"
  - "1x Micro-USB Cable"
description: "In this project we will use the Ultrasonic Sensor to measure distance, to detect objects and provide the O/P in common measurement units."
difficulty: "Easy"
documentationLinks: []
downloadableFiles: []
encryptedPayload: "U2FsdGVkX1+1GdkWQQcSBIGsSDkKqJanpQeDhtYnzCjkYFSPBdf35oWwVAirLcq5TS1l28Y3wOcSpKyfressgPnFU1x4eCe83bUJnD9sRro="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/basic-setup-for-ultrasonic-sensor-and-arduino-67ab93_cover.jpg"
lang: "en"
likes: 0
passwordHash: "947cfdcbefcba96312e7bf96acfaebddb9d6f8724a38aa32068f049e71673cf3"
price: 870
seoDescription: "An intuitive and simple ultrasonic distance monitor for beginners interested in Arduino sensor projects with clear feedback."
tags:
  - "ultrasonic"
  - "distance"
  - "measurement"
  - "arduino"
  - "beginners"
title: "Basic Setup for Ultrasonic Sensor and Arduino"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/CyXCwhRPXdk"
views: 1567