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.
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 Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (4.5V to 5.5V) |
2 | GND | Ground |
3 | Vout | Analog voltage output proportional to distance |
**Components Needed:**
- GP2YOA21YK0F IR Sensor
- Arduino UNO
- Breadboard and jumper wires
**Circuit Diagram:**
/*
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
}
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.