I suggest when you make it, you by a cheapo mouse, and pull it apart. you'll have the led and detector, and the rotary encoding wheel. I think there's PIC software for a mouse in the Microchip Databook, put basically all you need to do is find out how many pulses there are to the CM (or better still a 1M for accuracy), and divide the pulses by that to give distance.Mark