GP2Y0A21YK0F Infrared Sensor Features
Sharp GP2Y0A21YK0F is an IR sensor useing infrared wave to measure distance. The output of the sensor is analog voltage, which can be read easily by microcontroller’s ADC converter. This sensor can be used in industry and especially in robotics. The efficient range of this module is 10 to 80 cm.
You can download the datasheet of this sensor here.
GP2Y0A21YK0F Sensor Pinout
This module has 3 pins as follows:
- VCC: Module power supply – 5V
- GND: Ground
- OUT: The output of module that is analog voltage.
You can see pinout of this module in the image below.
Interfacing GP2Y0A21YK0F IR Sensor with Arduino
Step 1: Circuit
Connect the module to Arduino accoriding to the following image.
Step 2: Code
Upload the following code to Arduino.
/* modified on Sep 8, 2020 Modified by MohammedDamirchi from https://github.com/MajenkoLibraries/Average