The Grove Ultrasonic Ranger is a low-cost module you can use to measure distance. It has a Grove connector so you can easily connect it to the Grove Beginner Kit with a cable. And, Codecraft has an "Ultrasonic Ranger" block to read the distance.
"This Grove - Ultrasonic ranger is a non-contact distance measurement module which works at 40KHz. When we provide a pulse trigger signal with more than 10uS through signal pin, the Grove_Ultrasonic_Ranger will issue 8 cycles of 40kHz cycle level and detect the echo. The pulse width of the echo signal is proportional to the measured distance. ... Grove_Ultrasonic_Ranger's trig and echo signal share 1 SIG pin."
It is similar to the Ultrasonic Sensor HC-SR04, but it not directly compatible.
Review:
Grove cable
Connect a Grove cable to the Grove Ultrasonic Ranger
Connect the Grove cable to the D7 Grove socket on the Arduino microcontroller
Create a variable to store the ultrasonic sensor distance value
Use the "Ultrasonic Ranger" block (in the "Grove Digital" menu) to measure the distance and store the value in a variable
Use "Serial println" or "Serial Plot" to display the distance.
Upload and test:
Move your hand in front of the sensor and look at the distance numbers displayed on the Serial Monitor.
Do the numbers match the distance between your hand and the sensor (in cm.)? Check with a ruler.
What are the minimum and maximum distance limits of the Ultrasonic Ranger?
Create a sketch that uses the Ultrasonic Ranger.
Possible ideas:
Display the distance on the OLED
Play a note on the buzzer that indicates the distance
Your ideas?