Infrared proximity and range finder sensor made by Sharp. Part # GP2Y0A21YK has an analog output that varies from 3.1V at 10cm to 0.4V at 80cm. This sensor is not only detecting objects in the specified range, but also it can measure the distance of the detected object.
These connectors have three wires: ground, vcc, and the output signal. Because this sensor fire continuously and don't need any clock to initiate a reading cycle, it is easy to interface with any mirocontroller or Arduino
Theory of Operation
A pulse of IR light is emitted by the emitter. This light travels out in the field of view and either hits an object. If the light reflects off an object, it returns to the detector and creates a triangle between the point of reflection, the emitter, and the detector.
The angles in this triangle vary based on the distance to the object. The CCD array can then determine what angle the reflected light came back at and therefore, it can calculatethe distance to the object.
For sharp IR proximity sensor datasheet, please click here
For Sharp IR sensor Arduino Code for Object Detection, Please Click here