Just to add a drop ,

I've built a proximity sensor from IR led + IR-VIs Phototransistor for the pic.

Really a low parts count solution and works like charm in the range of 2-30cm if you apply 2 or 3 layers of filtering.

Anyway, stay away from light reflection methods if you need an accurate linear response according to distance, or be prepared for resolution problems and lookup tables