akssil-ga
Published

Wireless distance measurement using ultrasonic sensor

Using ultrasonic sensors to measure distance and display the result on an LCD.

IntermediateFull instructions provided674
Wireless distance measurement using ultrasonic sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
RGB LCD Shield Kit, 16x2 Character Display
RGB LCD Shield Kit, 16x2 Character Display
×1
Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Alphanumeric LCD, 16 x 2
Alphanumeric LCD, 16 x 2
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

The code of this project is shown below

The code is explained

Schematics

The circuit diagram

I have used fritzing to design this circuit diagram .

Code

The code of this project is shown below

Arduino
the code is very simple >|
#include <LiquidCrystal.h> // including the librery

// identifing the pins 

int rs=7;
int en=8;
int d4=9;
int d5=10;
int d6=11;
int d7=12;
int distance;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);

int tpin=2;
int epin=3;
double ptt;

int sval;
 

void setup() {
lcd.begin(16,2); //16,2 is a fix numbers shows the speed of an lcd 
pinMode(tpin,OUTPUT);
pinMode(epin,INPUT);
pinMode(spin,INPUT);

  
Serial.begin(9600);
}

void loop() {

lcd.setCursor(0,0); // controlling the lone and the columb of lcd





while(sval)
{
digitalWrite(tpin,LOW);
delay(2);
digitalWrite(tpin,HIGH);
delay(10);
digitalWrite(tpin,LOW);
ptt=pulseIn(epin,HIGH);

distance= 0.034*ptt/2;
lcd.print(distance); // printing the distance 

delay(50);



}
}

Credits

akssil-ga
5 projects • 5 followers
wameedh scientific club

Comments