Sense distance to an obstacle using an HC-SR04 ultrasonic distance sensor and a Raspberry Pi 4.
Translation to C of the Python code at: https://tutorials-raspberrypi.com/raspberry-pi-ultrasonic-sensor-hc-sr04/
Would probably work on other models of Raspberry Pi, possibly with some modifications to GPIO pin numbers.