#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C LCD( 0x27, 16,2);
#define TRIG 27
#define ECHO 26
int contador = 0;
long duration;
int distance;
void setup() {
Serial.begin(115200);
LCD.init ();
LCD.backlight ();
LCD.setCursor (0,0);
LCD.print("Senai CFP 1.01");
LCD.setCursor (0,1);
LCD.print("TEC.MECATRONICA");
delay(1000);
LCD.clear();
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
}
void loop() {
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);
duration = pulseIn(ECHO, HIGH);
contador = duration * 0.017;
delay(100);
LCD.setCursor (0,0);
LCD.print("Distancia:");
LCD.setCursor (0,1);
LCD.print(contador);
LCD.print(" cm ");
}