Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Arduino with LCD

This document outlines a procedure for measuring distance using an HC-SR04 ultrasonic sensor interfaced with an Arduino and displayed on an LCD. It details the components required, specifications of the ultrasonic sensor, and the working procedure including the circuit connections and Arduino code. The experiment successfully calculates and displays the distance to an object based on the time taken for ultrasonic waves to return after hitting the object.

Uploaded by

manojdhawan2017
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Arduino with LCD

This document outlines a procedure for measuring distance using an HC-SR04 ultrasonic sensor interfaced with an Arduino and displayed on an LCD. It details the components required, specifications of the ultrasonic sensor, and the working procedure including the circuit connections and Arduino code. The experiment successfully calculates and displays the distance to an object based on the time taken for ultrasonic waves to return after hitting the object.

Uploaded by

manojdhawan2017
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Aim: Calculate the distance to an object with the help of an ultrasonic sensor and display it on an LCD

Procedure:-In this experiment, we are going to interface Ultrasonic sensor HC-SR04 with Arduino and LCD Display. The ultrasonic sensor is
used to measure the distance. It acts as a Sonar. It sends an ultrasonic wave of a certain frequency that comes back after hitting the object
and calculates the time traveled by it. So let’s learn about Distance Measurement Using Arduino & HC-SR04 Ultrasonic Sensor.

Components Required: 1. Arduino Uno Board 2. Ultrasonic Sensor HC-SR04 3. 16*2 LCD Display 4. Breadboard 5. Connecting Wires
6. 5V Power Supply 7.Ultrasonic Sensor HC-SR04:

Description:-The HC-SR04 ultrasonic sensor uses sonar to determine the distance to an object like bats do. It offers excellent non-contact
range detection with high accuracy and stable readings in an easy-to-use package. Distance Measurement Using Arduino & HC-SR04 From
2cm to 400 cm or 1” to 13 feet. Its operation is not affected by sunlight or black material like sharp rangefinders are (although acoustically
soft materials like cloth can be difficult to detect). It comes complete with the ultrasonic transmitter and a receiver module.

The specifications of the ultrasonic distance sensor HC-SR04 are below:- 1. Minimum measuring range – 2 cm 2. Maximum measuring
range: 400 cm or 4 meter 3. Accuracy: 3 mm 4. Operating Voltage: +5V 5. Operating Current: 15mA 6. Working Frequency: 40
KHz 7. Trigger Input signal: 10us pulse 8. Measuring angle: 15 degrees Pins: 8 1. VCC: +5VDC 2. Trig: Trigger (INPUT) 3. Echo: Echo
(OUTPUT) 4. GND: GND

Working Procedure:-Ultrasonic sensors emit short, high-frequency sound pulses at regular intervals. These propagate in the air at the
velocity of sound. If they strike an object, then they are reflected back as echo signals to the sensor, which itself compute the distance to the
target based on the time-span between emitting the signal and receiving the echo. We will have to convert this time into cm to calculate the
distance traveled. We will use the following equation to calculate the distance. s = v * t The ultrasonic wave is basically a sound wave that
travels at a speed of 340 m/s (0.034 cm/s). The ultrasonic sensor is measuring the time it takes to hit the object and then come back but we
need only time that it takes to hit the object. So, we will divide it by 2.

Circuit Diagram and Connections

Trig and Echo pins of the ultrasonic sensor are connected to digital pin 3 & 2 of Arduino. V CC pin of the ultrasonic sensor is connected to the
5v pin of Arduino while the GND pin is connected to the GND of Arduino. SDA & SCL pin of the I2C module is connected to the A4 & A5 pin of
Arduino while V CC and GND pins are connected to the 5V & GND pin of Arduino. Copy this code then compile and upload it to your Arduino

Arduino Code:-

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);


const int trigPin = 3;

const int echoPin = 2;

long duration;

int distance;

void setup() {

lcd.begin(); // Initializes the interface to the LCD display

lcd.backlight();

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

Serial.begin(9600);

void loop() {

lcd.clear();

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = duration * 0.0340 / 2;

Serial.println("Distance");

Serial.println(distance);

lcd.setCursor(0, 0);

lcd.print("Distance: ");

lcd.print(distance);

lcd.print("cm");

delay(1000);

Output:

Result: The above experiment is designed and executed successfully using Arduino board.

You might also like