IR Distance Sensor with Cables - Sharp Infrared Sensor Module GP2Y0A02YK0F

AED 103.95

Low stock


GP2Y0A02YK0F 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.


Distance measuring range : 20 to 150 cm
Analog output type
Package size : 29.5×13×21.6 mm
Consumption current : Typ. 33 mA
Supply voltage : 4.5 to 5.5 V

Agency approvals/Compliance
Compliant with RoHS directive (2002/95/EC)

Touch-less switch
(Sanitary equipment, Control of illumination, etc. )
Sensor for energy saving
(ATM, Copier, Vending machine, Laptop computer,LCD monitor)
Amusement equipment
(Robot, Arcade game machine)

This is the Arduino code and video for Sharp Infrared Sensor Module

This video shows you how to measure the distance between 4cm to 180cm depending on the module, using Arduino. Sharp Analog output modules:

  1. Sharp IR Library 
  2. Sharp IR Library (from getHub)

 * Sharp IR (infrared) distance measurement module for Arduino
 * Measures the distance in cm.

 * Watch the video https://youtu.be/GL8dkw1NbMc

 *  * 

Original library: https://github.com/guillaume-rico/SharpIR

Updated by by Ahmad Nejrabi for Robojax.com
on Feb 03, 2018 at 07:34 in Ajax, Ontario, Canada
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purpose only.

  // Sharp IR code for Robojax.com

#define IR A0 // define signal pin
#define model 1080 // used 1080 because model GP2Y0A21YK0F is used
// Sharp IR code for Robojax.com
// ir: the pin where your sensor is attached
// model: an int that determines your sensor:  1080 for GP2Y0A21Y
//                                            20150 for GP2Y0A02Y
//                                            430 for GP2Y0A41SK   
2 to 15 cm GP2Y0A51SK0Fuse 1080
4 to 30 cm GP2Y0A41SK0F / GP2Y0AF30 seriesuse 430
10 to 80 cm GP2Y0A21YK0Fuse 1080
10 to 150 cm GP2Y0A60SZLFuse 10150
20 to 150 cm GP2Y0A02YK0Fuse 20150
100 to 550 cm GP2Y0A710K0Fuse 100550


SharpIR SharpIR(IR, model);
void setup() {
    // Sharp IR code for Robojax.com
 Serial.println("Robojax Sharp IR  ");

void loop() {
    // Sharp IR code for Robojax.com

  unsigned long startTime=millis();  // takes the time before the loop on the library begins

  int dis=SharpIR.distance();  // this returns the distance to the object you're measuring

  // Sharp IR code for Robojax.com

  Serial.print("Mean distance: ");  // returns it to the serial monitor
  unsigned long endTime=millis()-startTime;  // the following gives you the time taken to get the measurement
 Serial.print("Time taken (ms): ");
     // Sharp IR code for Robojax.com

Tags: sensor; module; ultrasonic; distance; proximity;