SHARP 2Y0D21

GP2Y0D21YK0F is a distance measuring sensor unit, composed of an integrated combination of PSD (position sensitive detector), IRED (infrared emitting diode) and signal processing circuit.


 * http://sharp-world.com/products/device/lineup/data/pdf/datasheet/gp2y0d21yk_e.pdf
 * http://bildr.org/2011/03/various-proximity-sensors-arduino/

Code arduino http://arduino103.blogspot.fr/2011/06/detecteur-de-proximite-infrarouge-sharp.html

D'après http://luckylarry.co.uk/arduino-projects/arduino-using-a-sharp-ir-sensor-for-distance-calculation/ // Sharp GP2Y0A02 int IRpin = 1;                                   // analog pin for reading the IR sensor

void setup { Serial.begin(9600);                            // start the serial port }

void loop { float volts = analogRead(IRpin)*0.0048828125;  // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3 float distance = 65*pow(volts, -1.10);         // worked out from graph 65 = theretical distance / (1/Volts)S - luckylarry.co.uk  Serial.println(distance);                       // print the distance delay(100);                                    // arbitary wait time. }