Project tutorial
Proximity Sensor with LCD

Proximity Sensor with LCD © GPL3+

A sound wave is sent out. The time it takes to return is used to calculate the distance of the object in front of the sensor.

  • 879 views
  • 0 comments
  • 1 respect

Components and supplies

Apps and online services

About this project

The project consists of a HR-SR04 which is used to measure the distance of an object in front of it, by sending out a sound wave & measuring the time it takes to come back.

The distance is then calculated and displayed on a 16x2 LCD.

Code

Source CodeArduino
#include <LiquidCrystal.h>

LiquidCrystal lcd(9,8,4,5,6,7);//(rs,e,d4,d5,d6,d7)

const int trigPin = 3, echoPin = 2;
long duration;
int distanceCM, distanceINCH;

void setup() {
  lcd.begin(16,2);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

}

void loop() {lcd.clear();delay(10);
  digitalWrite(trigPin, LOW); delayMicroseconds(2);
  digitalWrite(trigPin, HIGH); delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);//determine duration to calculate distance 
  distanceCM = duration*0.034/2;
  distanceINCH = duration*0.0133/2;

  lcd.setCursor(0,0);
  lcd.print("Distance: ");
  lcd.print(distanceCM); lcd.print(" cm");delay(10);
  
  lcd.setCursor(0,1);
  lcd.print("Distance: ");
  lcd.print(distanceINCH); lcd.print("inch");delay(100);
  
  if(distanceINCH>99){//for displaying purposes
      lcd.clear(); delay(10);
    }
  
}

Schematics

Wiring
Proximitysensor h0zhqbuadm

Comments

Created by

Electronics Hobbyists

Are you Electronics Hobbyists? Claim this project and add it to your profile.

This is mine

Posted by

Tr3v3n jaganath
Tr3v3n_Jaganath
  • 0 projects
  • 1 follower

Additional contributors

Published on

July 2, 2018
See similar projects
you might like

Similar projects you might like

Ultrasonic Sensor with Alarm, LCD and Temperature

Project tutorial by MichDragstar

  • 4,729 views
  • 7 comments
  • 19 respects

Ultrasonic Sensor with LCD Display Using 433MHz

Project tutorial by mcharrison500

  • 2,827 views
  • 0 comments
  • 15 respects

Displaying Sensor Values on LCD

by Wimpie van den Berg

  • 48,109 views
  • 4 comments
  • 38 respects

Soil Moisture Sensor With LCD Display

Project tutorial by Patel Darshil

  • 23,873 views
  • 6 comments
  • 41 respects

AI LCD friend!

Project tutorial by aip06

  • 3,733 views
  • 8 comments
  • 7 respects

Portable Arduino Temp/Humidity Sensor with LCD

Project tutorial by ThothLoki

  • 153,337 views
  • 115 comments
  • 185 respects
Add projectSign up / Login