Arduino is more powerful than you think! Today we will use the Ultrasonic Distance Sensor called HC-SR04 and test it to see how accurate it is.
First of all we will build a very simple setup and add a red LED and program it to flash red when the distance has reached.
Ultrasonic Distance Sensor Setup
I would say that this Ultrasonic sensor is quite accurate but not for very precise stuff, it has limit and the minimum distance it can measure is 2cm (0.78 inch) and maximum is 400cm (157.48 inches) also it cannot detect decimals like 2.5cm or 2.7cm it’s either 2cm or 3cm.
Watch the video below to see it in action.
On the first try I programmed the board to flash red when the book is below 10cm (3.9 inches)
Second try it will flash red if the book distance is below 4cm (1.5 inches)