#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define trig 16
#define echo 4
long tempo;
LiquidCrystal_I2C LCD(0x27,16,2);
void setup()
{
Serial.begin(115200);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
LCD.init ();
LCD.backlight();
LCD.setCursor(0,0);
LCD.print ("É OS GURI");
LCD.setCursor(0,1);
LCD.print ("tec.mecatronica");
delay (1000);
LCD.clear();
}
void loop()
{
LCD.setCursor(0,0);
LCD.print (tempo * 0.017 );
LCD.setCursor(0,1);
LCD.print ("medida em cm");
digitalWrite(trig , HIGH);
delayMicroseconds(10);
digitalWrite(trig , LOW);
tempo = pulseIn(echo,HIGH);
Serial.println(tempo * 0.017);
delay(500);
}