#define TRIG_PIN 2
#define ECO_PIN 9
void setup() {
// put your setup code here, to run once:
Serial(900);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECO_PIN, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(5);
digitalWrite(TRIG_PIN, HIGH);
// READING THE ECO SOUND
long duration = pulseIn(ECO_PIN,HIGH);
// MEASURE THE DISTANCE
long distance = (duration * 0.034 ) /2
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
//wait before reading
delay(2500);
}