#define ECHOPIN 2
#define TRIGPIN 3
float X=1.006;

void setup() {
  //General Ultrasonic Signal 
  Serial.begin(115200);
  pinMode(TRIGPIN, OUTPUT);
  pinMode(ECHOPIN, INPUT);
}

void loop() {
  digitalWrite(TRIGPIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIGPIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIGPIN, LOW);

  //Read Ultrasonic Signal 
  int duration = pulseIn(TRIGPIN, HIGH);
  float distance = duration * 0.034 * X / 2;
  Serial.print("Jarak: ");
  Serial.print(distance);
  Serial.println(" CM");
  delay(100);
}