Sharp 2Y0A21 IR Distance Sensor (NETMF 4.2)
The Sharp 2Y0A21 is a distance measuring sensor unit, composed of an integrated combination of PSD (position sensitive detector), IRED (infrared emitting diode) and signal processing circuit. The variety of the reflectivity of the object, the environmental temperature and the operating duration are not influenced easily to the distance detection because of adopting the triangulation method. This device outputs the voltage corresponding to the detection distance. So this sensor can also be used as a proximity sensor.
This class implements a simple driver, along with a polynomial calculated from the datasheet in order to convert ADC readings into distances in centimeters. It is much faster than other drivers which have been posted. Other drivers can take as many as 17ms to take 100 20-sample readings, while this driver can accomplish the same in only 6ms. As the sensor is quite noisy, the driver implements filtering of the readings in order to produce quite accurate results (given an accurate polynomial…).