Skip to Content

IR Distance Sensor With Cables Gp2y0a41sk0f 0a41sk 4-30cm

The GP2Y0A41SK0F is an analog distance measuring sensor ideal for detecting objects at close range (4 cm to 30 cm). It integrates a Position Sensitive Detector (PSD), an infrared-emitting diode (IR-LED), and signal processing circuitry. This sensor outputs a voltage that corresponds to the measured distance, making it suitable for proximity detection in a variety of applications.
84.00 AED 84.00 AED Tax Included
84.00 AED Tax Included

Not Available For Sale

This combination does not exist.

Terms and Conditions
30-day money-back guarantee
Shipping: 2-3 Business Days

 

Working Principle

  • The sensor emits infrared light using an IR-LED.
  • When this light hits an object, it reflects back to the PSD.
  • The PSD detects the reflected light, and the sensor outputs an analog voltage that corresponds to the distance of the object.
  • The output voltage is inversely proportional to the distance, making closer objects produce higher voltages.

 

Features

  • Accurate short-range distance measurement (4 to 30 cm)
  • Analog voltage output
  • Compact size and easy to integrate
  • Low power consumption
  • Uses a 3-pin JST PH connector

Wiring Connections

GP2Y0A41SK0F Sensor Arduino UNO
VCC (red wire) 5V
GND (black wire) GND
Signal (yellow wire) A0

 

Sample Code

#define sensor A0  // Sharp IR GP2Y0A41SK0F (4-30cm, analog)

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

void loop() {
  float volts = analogRead(sensor) * 0.0048828125; // Convert analog to voltage (5V / 1024)
  Serial.println(volts);

  int distance = 13 * pow(volts, -1); // Estimate distance from voltage
  delay(1000); // Delay for readability

  if (distance <= 30) {
    Serial.println(distance); // Print distance if within range
  }
}

Notes

  • No external library is required to use this sensor.
  • Ensure the sensor is connected to the correct analog pin on the Arduino.
  • The formula 13 * pow(volts, -1) is derived from the datasheet curve of output voltage vs. distance.

Understanding the Output

  • Why multiply by (5 / 1024)?
    Analog pins read a value from 0 to 1023 (10-bit ADC), corresponding to 0V to 5V. Multiplying by (5 / 1024) converts it to real voltage.
  • What does pow(volts, -1) do?
    This calculates the reciprocal of the voltage to approximate the distance based on the sensor's nonlinear response curve.

Getting Started

  1. Connect the Arduino to your PC using a USB cable.
  2. Open the Arduino IDE (install from arduino.cc if needed).
  3. Select the correct board from Tools > Board.
  4. Select the correct COM port from Tools > Port.

 

Applications

  • Proximity sensing
  • Obstacle detection in robots
  • Short-range object detection
  • Interactive systems and smart devices