If only everything in life was so simple, if only everything just "did what it says on the tin"!
The Sharp IR distance sensor is 4.5cm long, 1.5cm wide and high, not counting the bit sticking out for the connector.
It has three wires. I connected one to 5v, one to ground, and read the voltage coming out of the third with an Arduino....
int iAnalogValue=0; void setup(){ Serial.begin(9600); }; void loop(){ iAnalogValue=analogRead(0); Serial.println(iAnalogValue); };
... and that's all I needed to "see" whether something was in front of the sensor, and to see how far away it was.
At 7/10, I saw a similar sensor available online for £9, plus p&p.
My sensor was a "GP2Y0A21YF40F", bought from Sparkfun a while back. It seems that Sharp have produced a number of similar sensors.
In broad terms... I believe there are details incorporated in the design to improve reliability... the sensor consists of an IR LED and a IR receiver, both "looking" the same direction. When something comes close to the sensor module, the IR receiver "sees" the light from the LED bouncing back, and from what it "sees" measures the distance to the object.
With the program above, I get readings as follows, when I put my hand in front of the IR distance sensing module. Note: These figures are approximate. Is this device suitable for millimeter accurate measurements of not-constant targets? Did you see the price? Of course not. Will it give an idea of the proximity of an object? Yes. Can it detect an object's arrival in the sensor's field of view? Yes. If it was operating in a reasonably consistent context, would you get consistent results? I would expect so.
Reading Distance in cm 625 5cm 270 20 170 40 124 60 115 90If my hand is right against the sensor, I get a reading of 325. That number rises until my hand is about 5 cm from the sensor, after which the number falls. If my hand is more than about 90 cm from the sensor, I am not convinced that I could reliably detect it... there is a "background", or minimum response of about 50... but that number isn't steady. At 90 cm, the area the sensor "watches" is about 15cm wide.
If you visit 1&1's site from here, it helps me. They host my website, and I wouldn't put this link up for them if I wasn't happy with their service.
Click here to visit editor's Sheepdog Software (tm) freeware, shareware pages.
Click here to visit the homepage of my biggest site.
Click here to visit the homepage of Sheepdogsoftware.co.uk. Apologies if the "?FrmAht" I added to that link causes your browser problems. Please let me know, if so?
Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org
....... P a g e . . . E n d s .....