EmbeddedRelated.com
The 2026 Embedded Online Conference
GP2Y0A21YK0F

GP2Y0A21YK0F

Sharp
A popular analog infrared distance sensor for short-range measurements; useful if you prefer a simple analog output without I2C.
Active3,777 in stock

Overview

The Sharp GP2Y0A21YK0F is an analog infrared distance sensor designed for short to medium-range measurements. It provides a simple, direct analog voltage output proportional to the detected distance, eliminating the need for complex digital communication protocols like I2C or SPI. This sensor is a popular choice for applications requiring straightforward distance detection between 10 cm and 80 cm.

Why Choose This Part

Engineers choose the GP2Y0A21YK0F for its ease of use due to its analog output, which can be directly read by an ADC on any microcontroller without special libraries. It operates reliably within a 4.5V to 5.5V supply voltage range, making it compatible with common 5V systems. The compact through-hole package simplifies integration into prototypes and final products. Its robust performance in typical indoor conditions from -10 degrees C to 60 degrees C suits a wide array of consumer and industrial applications.

Applications

Touchless Switches
Implement hygienic, touch-free interfaces in sanitary equipment, lighting controls, and public kiosks by detecting hand proximity.
Robotics Navigation
Enable basic obstacle detection for robot cleaners, educational robots, and other autonomous systems operating in indoor environments.
Energy Saving Devices
Integrate into vending machines, ATMs, and copiers to detect user presence and activate or deactivate functions, conserving power.
Amusement Equipment
Provide interactive distance sensing for arcade games and robotic toys, enhancing user experience and gameplay.
Object Detection
Perform general-purpose object detection within its 10 cm to 80 cm range for automation tasks or safety monitoring.

Key Specifications

Output Type Analog
Current - Supply 40 mA
Sensing Distance 10 ~ 80cm
Voltage - Supply 4.5V ~ 5.5V
Operating Temperature -10degC ~ 60degC
Voltage - Output (Typ) @ Distance 400mV @ 80cm
Voltage - Output Difference (Typ) @ Distance 1.9V @ 10 ~ 80cm

Getting Started

To get started with the GP2Y0A21YK0F, connect its VCC and GND pins to a 5V power supply and the output pin to an analog input on a microcontroller like an Arduino or a Raspberry Pi Pico. Read the analog voltage and convert it to distance using the sensor's characteristic curve provided in the datasheet or through empirical calibration. Example code and wiring diagrams are widely available in the hobbyist and educational robotics communities.

Also Consider

HC-SR04 Parallax - This ultrasonic sensor module offers a similar distance range and simple digital pulse output, often at a lower cost, suitable for less precise applications.
GP2Y0A02YK0F Sharp - If a longer detection range is needed, the GP2Y0A02YK0F from Sharp provides analog distance sensing up to 150 cm with similar operational characteristics.
The 2026 Embedded Online Conference