The Sharp GP2Y0A02 IR Infrared Distance Sensor is an analog proximity sensor with a range from 20 to 150cm.
This optical sensor can detect objects up to 1.5 meters away. It works by emitting a powerful beam of invisible IR infrared light and then measuring the return reflection. Distance is read as an analog voltage suitable for use with most 5V microcontrollers.
Connect a regulated 5V power supply to the supply voltage (VCC) and ground (GND) connectors. Read the output voltage (VO) using an analog input on your microcontroller. The voltage output corresponds to the distance detected. See the datasheet for more details.
This sensor comes with a three pin JST connector cable.