# How can I measure the height of an object with a single sharp sensor (GP2Y0A21YK0F)?

I have one sharp sensor and I have to use it to measure the height of a block (6cm - 12 cm). How can I accomplish this ? Actually it is to be connected to a robot which will move near the box and determine its height.

The robot is like this: http://i.imgur.com/8qT8zeQ.jpg

If possible please suggest a solution that doesn't require moving the sensor. But any method will do fine.

It would seem to me like you could put the sensor at the top of a mast of known height $h$, looking down. Then the robot drives up to the block until the sensor feedback registers some distance other than $h$ (plus or minus some margin for noise, etc.)
$$h_{\mbox{block}} = h_{\mbox{mast}} - \mbox{sensor output}$$