IR SENSOR

Hi guys,

I am doing a personal project and for this I need to use something to calculate distance, but the ultrasonic sensor doesn't respond as well as I want (I would like to use a sensor that has a straight vision, like a "laser" - the infrared can resolve this for me - and not like a sonar/radar - ultrasonic sensor) , so my second idea was by using the infrared sensor, but i am not achieving how to use this! I know that it's graphic isn't linear, so I don't know how to write a formula/function that works on it.

So, if someone could help me, please, say another ideia or another way to measure distance by infrared sensor (I don't want to use the ultrasonic sensor) or (the better solution) give me the program or function/formula to transfer the analog output voltage or the analog value (achieved by a simple "analogRead") to the measure in centimeters or in meters!

Thanks to everybody that could help me! And sorry for my english

My sensor is: SHARP INFRARED SENSOR - 2Y0A02 F 5X (range: 20 - 150cm) http://www.elec.mn/category/9/362

It says here that this sensor provides an analog output that is proportional to the distance. Look at the Example files in the IDE to learn how to use the built-in function analogRead(). Use analogRead() to read an analog input pin that is attached to the IR sensor.

With the 5V reference..: Numbers from datasheet -> excel -> regression

float dist = 7864 * pow(analogRead(sensorpin),-0.882);