Calculating Length Based on Sensor Data

Posted by BSchlinker on Stack Overflow See other posts from Stack Overflow or by BSchlinker
Published on 2009-10-30T00:55:10Z Indexed on 2010/05/07 19:38 UTC
Read the original article Hit count: 275

Filed under:
|
|
|
|

I've got an IR sensor which writes its current information to a token which I then interpret in a C# application. That's all good -- no problems there, heres my code:

SetLabelText(tokens [1],label_sensorValue);
sensorreading = Int32.Parse(tokens[0]);
sensordistance = (mathfunctionhere);

Great. So the further away the IR sensor is from an object, the lower the sensor reading (as less light is reflected back and received by the sensor).

My problem is in interpreting that length. I can go ahead and get lets say "110" as a value when an object is 5 inches away, and then "70" as a value when an object is 6 inches away. Now I want to be able to calculate the distance of an object using these constants for any length.

Any ideas?

© Stack Overflow or respective owner

Related posts about math

Related posts about function