#define pintriger 26
#define pinecho 25

long durasi;
float cm, inch;

void setup() {
  // put your setup code here, to run once:
  pinMode(pintriger, OUTPUT);
  pinMode(pinecho, INPUT);
  Serial.begin(115200);
  Serial.println("Hello, ESP32!");
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(pintriger, LOW);
  delayMicroseconds(2);
  digitalWrite(pintriger, HIGH);
  delayMicroseconds(10);
  digitalWrite(pintriger, LOW);
  delayMicroseconds(2);

  durasi = pulseIn(pinecho, HIGH);
  cm = (durasi * 0.0343)/2;
  inch = cm / 2.54;
  Serial.print(cm);
  Serial.print("cm");
  Serial.print("\n");
  Serial.print(inch);
  Serial.print("Inch");
  Serial.print("\n");
  delay(50); // this speeds up the simulation
}