HOME - - - - - - - - Table of contents, my Arduino "How To" articles
Other material for programmers Delicious Bookmark this on Delicious   Recommend to StumbleUpon

Sharp GP2y... IR Distance Sensing Module

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  90
If 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.



   Search this site or the web        powered by FreeFind
 
  Site search Web search
Site Map    What's New    Search

The search engine is not intelligent. It merely seeks the words you specify. It will not do anything sensible with "What does the 'could not compile' error mean?" It will just return references to pages with "what", "does", "could", "not".... etc.
In addition to the tutorials for which this page serves as Table of Contents, I have other sites with material you might find useful.....

Sequenced set of tutorials on Arduino programming and electronics interfacing.
Tutorials about the free database supplied with Open Office version 2. (If you experienced Adabas with Star Office, ooBase is nothing like it!)
Some pages for programmers.
Using the parallel port of a Windows computer.


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.




Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!

Click here to visit editor's Sheepdog Software (tm) freeware, shareware pages.


And if you liked that, or want different things, here are some more pages from the editor of these tutorials....

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?

Click here to visit editor's pages about using computers in Sensing and Control, e.g. weather logging.



To email this page's editor, Tom Boyd.... Editor's email address. Suggestions welcomed!


Valid HTML 4.01 Transitional Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org


Why does this page cause a script to run? Because of the Google panels, and the code for the search button. Why do I mention the script? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....