Sharp IR error

Dear Arduino friends,

I have a Sharp GP2YA41SK0F IR sensor connected to my Arduino Uno and I am getting an error saying ‘class SharpIR’ has no member named ‘distance’ (please see copied error message below).

It worked a couple weeks ago when I first tested it, but now this error. Does anyone have a suggestion as to what may be causing this?

(The code I am trying to load is below the copied error message)

(Copied error message)
Arduino: 1.8.8 (Windows 10), Board: “Arduino/Genuino Uno”

C:\Users\jlcel\AppData\Local\Temp\arduino_modified_sketch_30835\SharpSensorCm.ino:50:26: warning: large integer implicitly truncated to unsigned type [-Woverflow]

SharpIR SharpIR(ir, model);


C:\Users\jlcel\AppData\Local\Temp\arduino_modified_sketch_30835\SharpSensorCm.ino: In function ‘void loop()’:

SharpSensorCm:62:19: error: ‘class SharpIR’ has no member named ‘distance’

int dis=SharpIR.distance(); // this returns the distance to the object you’re measuring


Multiple libraries were found for “SharpIR.h”
Used: C:\Users\jlcel\Documents\Arduino\libraries\SharpIR
Not used: C:\Users\jlcel\Documents\Arduino\libraries\robojax-sharp_IR-master
Not used: C:\Users\jlcel\Documents\Arduino\libraries\SharpIR-master
exit status 1
‘class SharpIR’ has no member named ‘distance’

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

(Code I am trying to load)

#include <SharpIR.h>

#define ir A0
#define model 430
// ir: the pin where your sensor is attached
// model: an int that determines your sensor: 1080 for GP2Y0A21Y
// 20150 for GP2Y0A02Y
// (working distance range according to the datasheets)

SharpIR SharpIR(ir, model);

void setup() {
// put your setup code here, to run once:

void loop() {

unsigned long pepe1=millis(); // takes the time before the loop on the library begins

int dis=SharpIR.distance(); // this returns the distance to the object you’re measuring

Serial.print("Mean distance: "); // returns it to the serial monitor

unsigned long pepe2=millis()-pepe1; // the following gives you the time taken to get the measurement
Serial.print("Time taken (ms): ");


So, why do YOU think the class has a member named distance()?

Post a link to the library, so wen can see what members it does have.