#define trig 50
#include <LiquidCrystal.h>
#define echo 51
LiquidCrystal lcd (1,2,4,5,6,7);
int duration; float distance;
void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trig,LOW);
delayMicroseconds(2);
digitalWrite(trig,HIGH);
delayMicroseconds(10);
digitalWrite(trig,LOW);
duration = pulseIn(echo , HIGH);
distance = duration * 0.034 / 2;
lcd.setCursor(3,0);
lcd.print("Distance:");
lcd.setCursor(5,1);
lcd.print(distance);
}