Experimenting with a distance measuring sensor
The SHARP 2Y0A21 proximity sensor measures distance by shining a beam of infrared light and uses a phototransitor to measure the intensity of the light that bounces back.
The bildr guide has explains the 2Y0A21 as well as other proximity sensors. The product description for the SHARP 2Y0A21 can be found here.
The wires connected to the sensor are stranded wires, so I soldered each end to a piece of solid core wire to make it easier to insert into the Arduino. I also wrapped electrical tape around the exposed wire connections to prevent short circuits.
The effective distance measuring range for this proximity sensor is 10-80cm. If an object is closer than the shortest distance, it reports a significantly higher analog output and is inconsistent with expected in-range results. For example, when an object is 1 cm away from the sensor, it reports an analogRead() value of 322. However, when the object is 5 cm away, the output is 655.
I attached the proximity sensor to fixed object (in my case, I used the clips of the soldering iron stand to secure the sensor).
With the proximity sensor in place, I took measurements from different distances.
With the proximity sensor in place, I took measurements from different distances.
Here are the analogRead() results:
20cm: 272
40cm: 145
60cm: 116
80cm: 104
Comments