Infrared Ranger

So I have a Sharp 2Y0A02. Here is some general information on the rangers
http://www.acroname.com/robotics/info/articles/sharp/sharp.html

I believe that Analogue In on Arduino returns 0-1023.

At rest (nothing in front of the IR ranger) I get a value of around 50, and up to 560. This is using Serial.println(val, DEC)

Any ideas how to get good values in using this sensor?

Making Things have a tutorial on their site
http://www.makingthings.com/resources/how-to/distance-measuring-sensor

Hi Chris:

that sensor puts out .2 to 2.5v, so your values are about right. If you want a larger range you should scale them up in software. You could scale them up in hardware, but you would just be interpolating imaginary values... it would just increase the spread between values. You can't get more detail than the sensor produces.

To scale them, try something like this, which will give you a range of 100-1023.

int value = 0
int newValue= 0

value = analogRead(1)  // read your pin
newValue = value * 2   // scale by 2

D

Thanks for clarifying.

Do you know how to cover this number into centimetres?

I guess the maximum range is 150cm, so a reading of 800 (out of 1023) is 78% = 117cm

?