A bit about the sensor

The SR04 is a very powerful and commonly used distance/proximity sensor. And that is what we are going to look at first. The SR04 sensor emits ultrasonic waves which are sound waves at such a high frequency (40 kHz) that they are inaudible to humans. When these waves come across an object, some of them get reflected. These reflected waves get picked up by the sensor and it calculates how much time it took for the wave to return. It then converts this time into distance.

We are firstly going to use this sensor to make a simple proximity switch. Basically, when you bring an object closer than the set threshold distance, an LED is going to light up.

This is the circuit that we need to construct. Again, be very careful about where ...

Get Arduino: Building exciting LED based projects and espionage devices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.