Distance sensor code testing
- Alex V
- May 26, 2019
- 1 min read
Updated: May 29, 2019
After the firsts test with the microphones I moved to the distance sensors.
The goal was to increase and decrease the brightness of the LED strip depending on how far you are
Test 1: PING
Using the monitor serie I was able to see that the PING sensor does not seem to work properly. The distance range shown in the Arduino software is always between 114-120 cm no matter how far the object is actually away from the sensor.
Test 2: Infrared
To first understand how an infrared sensor works I did some research
The infrared LED emitter emits an infrared pulsed light beam with a wavelength of 850nm +/- 70nm. A pulsed light is sent to minimize the influence of the ambient light and the color of the object in the measurement.
The position detector PSD (position sensitive detection) is actually a small linear CCD sensor that receives light reflected on any object in the path of the beam. The sensor uses triangulation to determine the distance of the sensor to objects located in front of the beam.

The analog output has a value of 2.5V to 20 cm, and 0.4 to 150cm. However, the answer is non-linear, so it is necessary to interpolate the value to obtain an adequate level of precision.

So I ended up finding this library to set it up : https://gist.github.com/reefwing/6bb74409774d5152f904
The end result was similar to the first test, a bunch of nonsense random numbers and no clear lecture.
Comments