#define trigPin 9
#define echoPin 10
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin,HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long durasi = pulseIn(echoPin, HIGH);
int jarak = durasi * 0.03421/2;
Serial.print("jarak :");
Serial.println(jarak);
delay(1000);
}