Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use GP2YOA21YKOF IR Sensor : Examples, Pinouts, and Specs

Image of GP2YOA21YKOF IR Sensor
Cirkit Designer LogoDesign with GP2YOA21YKOF IR Sensor in Cirkit Designer

Introduction

The GP2YOA21YK0F is an infrared (IR) sensor manufactured by Sharp, designed for distance measurement. It operates within a range of 10 to 80 cm and provides an analog voltage output proportional to the distance to the object. This sensor is widely used in robotics, automation, and proximity sensing applications due to its reliability and ease of integration.

Explore Projects Built with GP2YOA21YKOF IR Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
IR Obstacle Detection System with Relay-Controlled Gearmotors and Boost Converters
Image of LFR 1: A project utilizing GP2YOA21YKOF IR Sensor  in a practical application
This circuit consists of two FC-51 IR Obstacle Sensors connected to two KF-301 relays, which likely serve as triggers for switching the relays. Four gearmotors are powered through two XL6009E1 Boost Converters, which are likely used to step up the voltage from a 2-cell 18650 Li-ion battery pack. The relays appear to control the power flow to the boost converters, and thus to the gearmotors, based on the obstacle detection inputs.
Cirkit Designer LogoOpen Project in Cirkit Designer
Battery-Powered Sumo Robot with IR Sensors and DC Motors
Image of MASSIVE SUMO AUTO BOARD: A project utilizing GP2YOA21YKOF IR Sensor  in a practical application
This circuit is designed for a robotic system, featuring a Massive Sumo Board as the central controller. It integrates multiple FS-80NK diffuse IR sensors and IR line sensors for obstacle detection and line following, respectively, and controls two GM25 DC motors via MD13s motor drivers for movement. Power is supplied by an 11.1V LiPo battery.
Cirkit Designer LogoOpen Project in Cirkit Designer
Battery-Powered Robotic System with Raspberry Pi Pico and Motor Driver
Image of Sumobot Schematic: A project utilizing GP2YOA21YKOF IR Sensor  in a practical application
This circuit is a sensor and motor control system powered by a 3.7V LiPo battery, regulated to power various components including a Raspberry Pi Pico microcontroller. The system includes light sensors, an IR receiver, and an RF receiver to gather input, and uses a motor driver to control two DC motors based on the sensor inputs.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino-Based IR Sensor Array with LED Indicators
Image of mixed: A project utilizing GP2YOA21YKOF IR Sensor  in a practical application
This circuit uses an Arduino UNO to interface with multiple IR sensors, each connected to a different digital input pin. The IR sensors are powered by the Arduino's 5V and GND pins, and the setup is likely intended for detecting objects or motion in various zones.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with GP2YOA21YKOF IR Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of LFR 1: A project utilizing GP2YOA21YKOF IR Sensor  in a practical application
IR Obstacle Detection System with Relay-Controlled Gearmotors and Boost Converters
This circuit consists of two FC-51 IR Obstacle Sensors connected to two KF-301 relays, which likely serve as triggers for switching the relays. Four gearmotors are powered through two XL6009E1 Boost Converters, which are likely used to step up the voltage from a 2-cell 18650 Li-ion battery pack. The relays appear to control the power flow to the boost converters, and thus to the gearmotors, based on the obstacle detection inputs.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of MASSIVE SUMO AUTO BOARD: A project utilizing GP2YOA21YKOF IR Sensor  in a practical application
Battery-Powered Sumo Robot with IR Sensors and DC Motors
This circuit is designed for a robotic system, featuring a Massive Sumo Board as the central controller. It integrates multiple FS-80NK diffuse IR sensors and IR line sensors for obstacle detection and line following, respectively, and controls two GM25 DC motors via MD13s motor drivers for movement. Power is supplied by an 11.1V LiPo battery.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Sumobot Schematic: A project utilizing GP2YOA21YKOF IR Sensor  in a practical application
Battery-Powered Robotic System with Raspberry Pi Pico and Motor Driver
This circuit is a sensor and motor control system powered by a 3.7V LiPo battery, regulated to power various components including a Raspberry Pi Pico microcontroller. The system includes light sensors, an IR receiver, and an RF receiver to gather input, and uses a motor driver to control two DC motors based on the sensor inputs.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of mixed: A project utilizing GP2YOA21YKOF IR Sensor  in a practical application
Arduino-Based IR Sensor Array with LED Indicators
This circuit uses an Arduino UNO to interface with multiple IR sensors, each connected to a different digital input pin. The IR sensors are powered by the Arduino's 5V and GND pins, and the setup is likely intended for detecting objects or motion in various zones.
Cirkit Designer LogoOpen Project in Cirkit Designer

Technical Specifications

Key Technical Details

Parameter Value
Manufacturer Sharp
Part Number GP2YOA21YK0F
Operating Voltage 4.5V to 5.5V
Average Current Consumption 30 mA
Distance Measuring Range 10 cm to 80 cm
Output Type Analog Voltage
Output Voltage Range 0.4V to 2.4V
Response Time 38 ms
Operating Temperature -10°C to +60°C

Pin Configuration and Descriptions

Pin Number Pin Name Description
1 VCC Power supply (4.5V to 5.5V)
2 GND Ground
3 Vout Analog voltage output proportional to distance

Usage Instructions

How to Use the Component in a Circuit

  1. Power Supply: Connect the VCC pin to a 5V power supply and the GND pin to the ground of your circuit.
  2. Output Signal: Connect the Vout pin to an analog input pin of a microcontroller (e.g., Arduino UNO) to read the distance measurement.

Important Considerations and Best Practices

  • Power Supply: Ensure a stable 5V power supply to avoid fluctuations in the sensor's output.
  • Mounting: Mount the sensor securely to avoid vibrations that could affect the accuracy of the measurements.
  • Interference: Avoid placing the sensor near sources of infrared interference, such as direct sunlight or other IR-emitting devices.
  • Calibration: Calibrate the sensor in your specific environment to account for any variations in readings.

Example Circuit with Arduino UNO

**Components Needed:**
- GP2YOA21YK0F IR Sensor
- Arduino UNO
- Breadboard and jumper wires

**Circuit Diagram:**

Circuit Diagram

Sample Arduino Code

/*
  GP2YOA21YK0F IR Sensor Example
  This code reads the analog voltage output from the GP2YOA21YK0F IR sensor
  and converts it to a distance measurement.
*/

const int sensorPin = A0; // Analog input pin connected to Vout of the sensor
int sensorValue = 0;      // Variable to store the sensor value
float distance = 0;       // Variable to store the calculated distance

void setup() {
  Serial.begin(9600); // Initialize serial communication at 9600 baud
}

void loop() {
  sensorValue = analogRead(sensorPin); // Read the analog value from the sensor
  distance = map(sensorValue, 0, 1023, 10, 80); // Convert the analog value to distance
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
  delay(100); // Wait for 100 milliseconds before the next reading
}

Troubleshooting and FAQs

Common Issues Users Might Face

  1. Inaccurate Readings: The sensor may provide inaccurate readings if not properly calibrated or if there is interference from other IR sources.
  2. No Output: Ensure that the sensor is correctly powered and that all connections are secure.
  3. Fluctuating Readings: This can be caused by an unstable power supply or vibrations affecting the sensor.

Solutions and Tips for Troubleshooting

  • Check Connections: Verify that all connections are secure and that the sensor is properly powered.
  • Stable Power Supply: Use a regulated power supply to ensure stable voltage.
  • Calibration: Perform calibration in the specific environment where the sensor will be used.
  • Shielding: Shield the sensor from direct sunlight or other IR sources to avoid interference.

FAQs

Q: Can the GP2YOA21YK0F detect objects beyond 80 cm? A: No, the sensor is designed to measure distances within the range of 10 to 80 cm.

Q: How do I calibrate the sensor? A: Calibration involves comparing the sensor's output with known distances and adjusting your code or setup accordingly.

Q: Can I use the sensor in outdoor environments? A: The sensor can be used outdoors, but it should be protected from direct sunlight and extreme weather conditions.


This documentation provides a comprehensive guide to using the GP2YOA21YK0F IR sensor, ensuring both beginners and experienced users can effectively integrate it into their projects.