#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define LED 5
LiquidCrystal_I2C LCD(0x27, 16, 2);
const int pinChannel1 = 0;
const int freq = 1000;
const int resolution = 10;
int value_PWM;
#define TRIG 26
#define ECHO 25
void setup()
{
Serial.begin(115200);
pinMode(26, OUTPUT);
pinMode(25, OUTPUT);
LCD.init();
LCD.backlight();
LCD.setCursor(0,0);
LCD.print("Fah");
LCD.setCursor(0,1);
LCD.print("399.97");
ledcAttachPin(LED,pinChannel1);
}
void loop()
{
digitalWrite(26, LOW);
delay(10); // this speeds up the simulation
digitalWrite(26, HIGH);
delay(10);
digitalWrite(26, LOW);
int Echopulse = pulseIn(25,HIGH);
float cm = Echopulse / (29.41*2);
Serial.print(Echopulse);
Serial.print("microsec or cm =");
Serial.println(cm);
delay(100);
}