How to code an ultrasonic sensor in Arduino?

How to code an ultrasonic sensor in Arduino?
You can refer to the following link:
https://wiki.dfrobot.com/URM09_Ultrasonic_Sensor_(Gravity_Analog)_SKU_SEN0307

The product's wiki contains corresponding usage instructions and sample codes. It is recommended to refer to the wiki for code writing and product use.
Taking the "Gravity: URM09 Analog Ultrasonic Sensor" (SKU: SEN0307) as an example, it uses an analog voltage output method and can be connected to the mainboard through the Gravity 3Pin analog sensor cable. The module is connected to the UNO through the A1 analog interface, as shown in the figure below.

Tutorial on Arduino programming ( Distance Measurement )
The module will output analog voltage proportional to distance. After ADC sampled and output these data, the distance value can be obtained with a simple processing step.

Sample Code

