The sensor looks like a pair of eyes
To measure, pulse the trigger pin (various sources say 10 microseconds to 5 milliseconds), wait for the ECHO output to go high and measure the time for it to return low. The time is proportional to the distance.
We can use a library for this, and it works better than a simple version that we might quickly put together.
example code
#include <NewPing.h>
#define ECHO 7
#define TRIGGER 8
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER, ECHO, MAX_DISTANCE);
// the setup routine runs once when you press reset:
void setup() {
Serial.begin(115200);
}
// the loop routine runs over and over again forever:
void loop() {
Serial.print("Distance: ");
Serial.print(sonar.ping() / US_ROUNDTRIP_CM);
Serial.println("cm");
delay (500);
}