You want to use a HC-SR04 Ultrasonic Range Sensor with BeagleBone Black.
The HC-SR04 Ultrasonic Range Sensor (shown in below) works by sending a trigger pulse to the Trigger input and then measuring the pulse width on the Echo output. The width of the pulse tells you the distance.
Wire the sensor as shown below. Note that the HC-SR04 is a 5 V
device, so the banded wire (running from P9_7
on the Bone to VCC on the range finder) attaches the HC-SR04 to the Bone's 5 V power supply.
This code is more complex than others, because we have to tell the device when to start measuring and time the return pulse.