My 2WD (two-wheel drive) buggy needs some sort of obstacle avoidance sensor so the HC-SR04 I've had in my components drawer since my PIC days came out. Using this ultrasonic detector is easy and gives accurate distance results up to about 3cm from the device.
In this video we've added it to the 2WD buggy we're slowly building (very cheap kit from the Gar East) and this gives it obstacle detection capabilities.
The sketches I used (first one without a library, second one with the NewPing library) are here in this GitHub)
https://github.com/RalphBacon/HC-SR04-Ultrasonic-Sensor
Where I bought a pack of 5 HC-SR04s (UK site but readily available)
https://www.amazon.co.uk/dp/B01M0QL1F1
And where I SHOULD have bought them if I had had the time
https://www.aliexpress.com/item/hc-sr04-ultrasonic-ranging-module-smart-car-ultrasonic-sensor-module/32531458441.html
Where I bought the laser cut mounting bracket
http://www.ebay.co.uk/itm/262069871882
The Far Eastern version of the laser cut mounting bracket (you can get them in RED and YELLOW too!)
https://www.aliexpress.com/item/Cartoon-Ultrasonic-Sensor-Mounting-Bracket-for-HC-SR04-Smart-Car-Red-Blue-Color-free-shipping/1954761236.html
The UK eBay link for the 3D printed mounting bracket
http://www.ebay.co.uk/itm/152275416269
I couldn't find a Far Eastern version of the 3D printed one, so if you do find one please do post it in the comments under the video!
Finally, if you really are that interested here's the location of that "wiring_private.h" file:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino
---
If you like this video please give it a thumbs up, share it and if you're not already subscribed please consider doing so :)
My channel is here:
------------------------------------------------------------------
https://www.youtube.com/c/RalphBacon
------------------------------------------------------------------
How can I remember this? Memory tip: "See" Ralph Bacon, geddit?
You can also use this link: https://www.youtube.com/RalphBacon