กลับไปหน้ารวมไฟล์
arduino-16x2-lcd-display-with-distance-sensor-ec57f0-en.md

Using Distance Sensor with 16x2 LCD Display

In here I am going to show you how to make print distance using distance Sensor.

So we have to need distance sensor.

And LCD display with I2C module

Thank you

Project Overview

This project demonstrates how to measure distance using an ultrasonic sensor and display the results in real-time on a 16x2 Character LCD. By using an I2C interface for the LCD, we significantly reduce the number of wires required, making the project cleaner and easier to build.

Hardware Components

  • Arduino UNO: The brain of the project.
  • HC-SR04 Ultrasonic Sensor: Uses sonar to determine the distance to an object.
  • 16x2 LCD with I2C Module: Displays the distance data. The I2C module (PCF8574) allows the LCD to be controlled using only 2 data pins (SDA and SCL).

How It Works

  1. Distance Sensing: The HC-SR04 sensor works by sending an ultrasonic pulse (Trig pin) and measuring the time it takes for the echo to bounce back (Echo pin). The Arduino calculates the distance using the speed of sound formula: Distance = (Time * 0.034) / 2.
  2. I2C Communication: Instead of using 6-10 digital pins to control the LCD, the I2C backpack communicates with the Arduino over the I2C bus. This requires the LiquidCrystal_I2C library.
  3. Display Logic: The Arduino continuously updates the LCD with the latest distance value. If the object moves, the numbers on the screen change instantly.

Wiring and Setup

  • LCD I2C: VCC to 5V, GND to GND, SDA to A4 (on Uno), SCL to A5 (on Uno).
  • HC-SR04: VCC to 5V, GND to GND, Trig to Pin 9, Echo to Pin 10.
  • I2C Address: Most I2C LCDs use the address 0x27 or 0x3F. If your screen is blank, you may need to adjust the contrast potentiometer on the back of the I2C module.

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

title: "Arduino 16x2 LCD Display with Distance Sensor"
description: "Print distance on Arduino LCD Display using I2c"
author: "jehankandt"
category: ""
tags:
  - "lights"
  - "communication"
views: 56124
likes: 2
price: 870
difficulty: "Intermediate"
components:
  - "1x Arduino UNO"
  - "1x I2C 16x2 Arduino LCD Display Module"
  - "1x Ultrasonic Sensor - HC-SR04 (Generic)"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles:
  - "https://projects.arduinocontent.cc/b3db9c95-2c2c-4578-80ab-d53ecfa0bcb7.ino"
documentationLinks: []
passwordHash: "ab915cb1fb8a97c9211c05807ff563f28b1dcf3e24ec4fdde2a32bb534b90f5e"
encryptedPayload: "U2FsdGVkX1/x+6CENsnOMXHFqFL5m1r5/aIhneh/qhTSXexAxVphpzvV079nIRC1Us4ANWGBiMW2FGlxjuo3aOUYKOSf7/Voimvv6yABNwqQ6kHGstO4/D2GX5LuVKUcx0Yy4iBz5mHYzeJB48AFqpLWaTNbyYzV6TclI00IGi4="
seoDescription: "Learn how to display Distance Sensor readings on an Arduino 16x2 LCD Display using the I2C interface. Simple DIY project guide."
videoLinks: []
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/arduino-16x2-lcd-display-with-distance-sensor-ec57f0_cover.jpg"
lang: "en"