Distance measurement using Arduino and Sharp sensor GP2Y0A41SK0F

Distance measurement using Arduino and sensor Sharp GP2Y0A41SK0F

The sensor allows you to measure distances. This hotel is located closer to the sensor, the voltage at the output above. The following example can be used with any analog distance sensor from Sharp.


We will need the following items:


Connect the sensor with Arduino:

The sensor using the Arduino you should connect the layout as follows:


Module SharpPin Arduino
35 V



The terminals of the sensor Sharp.



Connection scheme of sensor with the Arduino Uno.


Program for Arduino

In the example, we used the following code:


int sensor = A1; //analog pin A1 is connected to the signal from the sensor 

void setup(){ 
 Serial.begin(9600); //initialize serial monitor 
 Serial.println("Test of spacing"); 

void loop(){ 
 int layer count = analogRead(sensor); //read the value from the sensor 
 Serial.println(odl); //display it on the monitor 

 delay(200); //delay between consecutive readings 


The result of the program can be viewed on the serial monitor:


The program displays the values from 0 to 1023. In order to convert them to distance in centimeters, you must act according to the module documentation.