This popular sensor made by Sharp produces an analog output that varies from 3.1V at 10cm to 0.3V at 80cm.
Based on "typical values" from Sharp, the formula to translate output voltage ratio into Distance is:
Distance (cm) = 4.8/(VoltageRatio - 0.02)
This sensor can find the distance to objects that present a very narrow edge such as a wall at a very sharp angle.
Note: The output of this sensor will vary from unit to unit, and based on the characteristics of the target (reflectance, size, direction of motion, and object alignment). Our formula is based on the data provided by Sharp. If you find that you are not getting good results with the standard formulas, you may want to derive your own formula to better characterize your situation.
|Sensor Output Type
|Measurement Distance Min
|Measurement Distance Max
|Response Time Max
|Supply Voltage Min
||4.5 V DC
|Supply Voltage Max
||5.5 V DC
|Current Consumption Max
|Operating Temperature Min
|Operating Temperature Max
If you are not getting good results with the standard formula, have a look at the product datasheet which has good notes on what can affect the sensor's performance