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.html#distance-sensor-hc-sr04.
We've started to use many pins on the Raspberry Pi. When trying to find pins to use, I highly recommend visiting the Raspberry Pi GPIO at https://pinout.xyz/.
There are many scholarly articles on more interesting or sophisticated object behavior. I recommend reading Simple, Real-Time Obstacle Avoidance Algorithm (https://pdfs.semanticscholar.org/519e/790c8477cfb1d1a176e220f010d5ec5b1481.pdf) for Mobile Robots for a deeper look at these behaviors.
For getting to know Flask, the Flask website at http://flask.pocoo.org is highly recommended. I also recommend the book Mastering Flask (https://www.packtpub.com/web-development/mastering-flask), written by Jack Stouffer, published by Packt.
Jinja2, the Python template engine we used, is documented for reference at http://jinja.pocoo.org/.
The HTML used in this chapter is extremely simple. To get a deeper look into the ways you could enhance the simple menu system, I recommend the eLearning video guide Beginning Responsive Web Development with HTML and CSS [eLearning] (https://www.packtpub.com/web-development/beginning-responsive-web-development-html-and-css-elearning-video). Another good place to get to grips with HTML is https://www.freecodecamp.org/, which offers assessed online courses in coding web pages.