กลับไปหน้ารวมไฟล์
proximity-sensor-with-lcd-afb182-en.md

Project Summary

The Proximity Sensor with LCD project is a practical tool for building digital measuring tapes, obstacle detection systems, or parking aids. It combines high-accuracy ultrasonic ranging with a real-time visual output on a character liquid crystal display (LCD).

Technical Principles

  • Ultrasonic Ranging (HC-SR04): The sensor works like sonar in nature, emitting a 40kHz sonic burst and then measuring the time it takes for that burst to bounce off an object and return to the receiver (Echo pin).
  • Distance Calculation: Using the speed of sound (approx. 343 m/s), the Arduino calculates the total travel time. Since the sound must travel to the object AND back, the formula is:
Distance (cm) = (Time * 0.0343) / 2
  • Display Output: A 16x2 LCD is used to show the distance in centimeters or inches. The Arduino uses the LiquidCrystal library to format this data for the user.

Hardware Wiring

  • HC-SR04 Module:
    • VCC to 5V
    • GND to Ground
    • Trig to Digital Pin 9 (Trigger burst)
    • Echo to Digital Pin 10 (Receive pulse)
  • 16x2 LCD Module (Standard Parallel):
    • RS to Pin 12
    • Enable to Pin 11
    • Data Pins (D4-D7) to Pins 5, 4, 3, 2
    • Contrast Potentiometer for clear text visibility.

Software Execution

The code is structured into two main parts:

  1. Pulse Generation: The code pulls the Trig pin HIGH for exactly 10 microseconds to start the sonic burst.
  2. Pulse Measurement: The pulseIn() function measures the length of the Echo pulse, providing the time in microseconds.
  3. Data Refresh: The LCD is cleared and updated every few hundred milliseconds to provide a smooth, continuous measurement.

Use Cases

  • Digital Ruler: Accurate measurements for hardware and crafting.
  • Smart Trash Bin: Detects when your hand or an object is close to automatically open the lid.
  • Water Level Monitor: Placing the sensor at the top of a tank can detect how much water is remaining based on the distance to the surface.

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

title: "Proximity Sensor with LCD"
description: "Distance measurement using ultrasonic sensor and display on 16x2 LCD."
author: "shassandanish1"
category: "Sensors & Environment"
tags:
  - "proximity"
  - "ultrasonic"
  - "lcd"
views: 3154
likes: 0
price: 1120
difficulty: "Easy"
components:
  - "1x Arduino UNO"
  - "1x Ultrsonic Sensor HC-SR04"
  - "1x Alphanumeric LCD, 16 x 2"
  - "10x Jumper wires (generic)"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles: []
documentationLinks: []
passwordHash: "..."
encryptedPayload: "..."
seoDescription: "Distance measurement using ultrasonic sensor (proximity) and display on 16x2 LCD with Arduino."
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/proximity-sensor-with-lcd-afb182_cover.jpg"
lang: "en"