GP2Y0A41SK0F Infrared Sensor Features
Sharp GP2Y0A41SK0F is an IR sensor that uses infrared wave to measure distance. The sensor’s output is analog, which can be easily read by microcontroller’s ADC converter. This sensor can be used in industry and especially in robotics. This sensor has an efficient range of 4cm to 30 cm.
Note
The sensor’s accuracy will decrease at distances over 40cm.
You can download the datasheet of this sensor here.
GP2Y0A41SK0F Infrared Distance Detection Sensor Datasheet
1 file(s) 858.45 KB
GP2Y0A41SK0F Infrared Sensor Pinout
This module has 3 pins as follows:
- VCC: Module power supply – 5V
- GND: Ground
- OUT: The output of the module which is analog voltage.
You can see the pinout of this module in the image below.
Required Material
Hardware component
Software Apps
Interfacing GP2Y0A41SK0F Sensor with Arduino
Step 1: Circuit
Connect the sensor to Arduino according to the following image.
Step 2: Code
Install following library on your Arduino board.
Note
If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library
Upload the following code to your Arduino board.
/*
modified on Sep 8, 2020
Modified by MohammedDamirchi from https://github.com/MajenkoLibraries/Average
Home
*/
#include <Average.h>
// Reserve space for 10 entries in the average bucket.
// Change the type between < and > to change the entire way the library works.
Average<float> ave(10);
void setup() {
Serial.begin(9600);
}
void loop() {
int minat = 0;
int maxat = 0;
// Add a new random value to the bucket
ave.push((13 * pow(analogRead(A0)*0.0048828125, -1))+1.8);
Serial.println(ave.mean());
delay(100);
}
After running the code, you will see the following image in the serial output.