This GP2Y0A21 sensor from Sharp can be used to detect objects within the range 10cm to 80cm. The sensor senses for objects ahead of it and outputs an analog voltage corresponding to the distance between the sensor and the object. You can easily read this signal from the ADC for an Arduino/Raspberry Pi or a Microcontroller and get the distance of the object. This Sharp sensor is great to add obstacle avoidance or motion sensing to your robot or any other project. The sensor comes with a compatible 3 pin JST 3-pin connector with crimped wires. Since it is a very popular distance sensor, sample codes, tutorials and libraries for Arduino/Raspberry Pi and popular microcontroller are readily available. Features
Operating Voltage: 4.5V - 5.5V
Average current consumption: 30 mA (note: this sensor draws current in large, short bursts, and the manufacturer recommends putting a 10 µF capacitor or larger across power and ground close to the sensor to stabilize the power supply line)
Size: 44.5 mm × 18.9 mm × 13.5 mm (1.75? × 0.75? × 0.53?)
Weight: 3.5 g (0.12 oz)
Range: 10cm(4") to 80cm(30")
Gives an analog output corresponding to the distance of the object detected
No need of any external circuit for using this sensor.