The VCNL4000 sensor is a nice way to add a small-distance proximity sensor to your microcontroller project. For longer distances (in the range of cm, you can use a SHARP IR distance sensor, but those are only good if the object is over 10 cm away. The VCNL4000 is designed for much shorter distances, no more than 200mm (about 7.5″) and under our experimentation we found it worked best at distances of about 10-150mm. It would be good for say detecting when a hand moved nearby, or before a robot smacks into a wall. The sensor also has an ambient light sensor built in.
VCNL4000 Proximity/Light sensor - [Link]