# Alternate ways of measuring distance (lateral)?

I'm working on a micromouse, a small autonomous robot that traverses a maze.
I need an efficient way to measure lateral distance to walls and I'm looking at the Sharp GP2D120 but looking at the datasheet, it has long typical response time of 39ms, is quite bulky, and has a minimum distance of 4cm.
Can you recommend a better sensor (that possibly has a lower minimum distance)?

I was wondering what are some alternate ways of measuring distance? I have seen other micromice use IR LEDs and it was interesting but I'm not sure how it works.

Any input is appreciated. Thanks!

• +1 for mentioning IR LEDs. I was just planing to ask a question how to use them to measure distance. Commented Oct 30, 2011 at 20:10

I have read somewhere (I think the Arduino forums) that sharp no longer manufactures these sensors (though that can be hearsay). I do know however that they are quite expensive compared to much simpler solutions.

The simplest would be a IR LED - IR phototransistor combination:

Phototransistor on left, led on right

You would power the IR LED (remeber the limiting resistor!) and then use the phototransistor to pick it up. The voltage drop over the phototransistor will be proportional to the intensity of the IR light it picks up which is proportional to the distance the emitter and detector are from the reflecting surface.

Pointers (Personal Experience):

• It will take some experimentation and calibration to find the correct voltage - distance relationship
• The voltage will vary depending on the reflectivity of the reflector to IR light.
• The detector and reflector will need to be shielded from each other in order to gain a accurate measurement.
• This type of sensor is only reasonaly accurate. Keep it in mind.
• The detector is susceptible to outside sources of IR light, including the sun, incandescent light and florescent light bulbs.

There are many links on the internet on how to use said components. Take a look here: http://letsmakerobots.com/node/2907

Lastly, this method (I have found) is only accurate over small distances (not more than 20cm I'd say). For longer ranges you should consider ultrasonics or those fancy Sharp sensors.

I suggest you look at how real mice measure close distances:

Could you arrange to have some flexible wire (piano wire) attached to microswitches to emulate the mouse's whisker?

This can even be purchased as an off-the-shelf part:

You can use ultrasound, which involves sending short burst at say 40kHz and timing how long it takes for the reflection.

Here are a couple of PIC based links:
PIC Sonar
PIC distance measuring

This will still be bulky as the transducers are quite large, although it would typically have more range than the IR option. Minimum distance will depend on the ultrasound frequency and the speed of the microcontroller, higher being better for both. I think 5cm to a few metres should be achievable quite easily.