#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define TRIG 2
#define ECHO 4
#define b1 16
#define b2 17
int contador = 0, litro = 0, t_p = 0;
long duration;
int distance;
bool s_e = 0, s_s = 0;
LiquidCrystal_I2C LCD(0x27, 16, 2);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("by Gabriel Luz");
LCD.init();
LCD.backlight();
LCD.setCursor(0,0);
LCD.print(" Gabriel Luz ");
LCD.setCursor(0,1);
LCD.print("TEC.MECATRONICA");
delay(1000);
LCD.clear();
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
pinMode(b1, OUTPUT);
pinMode(b2, OUTPUT);
}
void loop() {
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);
duration = pulseIn(ECHO, HIGH);
contador = duration * 0.017;
LCD.setCursor(0, 0);
LCD.print(contador);
LCD.print(" cm ");
delay(10);
}