There are a number of other tutorials on these sensors on the internet worth reading for further knowledge and experimentation:
- First, I recommend looking at the datasheet for the sensor. You can search for the HC-SR04 datasheet. The Mouser link for it can be found at https://www.mouser.com/ds/2/813/HCSR04-1022824.pdf, but be warned that this may change.
- ModMyPi has a tutorial with an alternative way to wire these and level shift their IO: https://www.modmypi.com/blog/hc-sr04-ultrasonic-range-sensor-on-the-raspberry-pi.
- Raspberry Pi Tutorials also has a breadboard layout and Python script, using RPi.GPIO instead of gpiozero, at https://tutorials-raspberrypi.com/raspberry-pi-ultrasonic-sensor-hc-sr04/.
- GPIOZero has its own class for dealing with the distance sensor, but it is only suitable for longer distances: https://gpiozero.readthedocs.io/en/stable/api_input...