error: no matching function for call to 'SharpIR::SharpIR(const uint8_t&, int,

Hi guys i am having trouble uploading this code, keeps giving me the error above.

#include <SharpIR.h>

#define ir A0
#define model 1080

boolean done=false;

SharpIR sharp(ir, 25, 93, model);

// ir: the pin where your sensor is attached
// 25: the number of readings the library will make before calculating a mean distance
// 93: the difference between two consecutive measurements to be taken as valid
// model: an int that determines your sensor: 1080 for GP2Y0A21Y
// 20150 for GP2Y0A02Y
// (working distance range according to the datasheets)

void setup(){

Serial.begin(9600);
pinMode (ir, INPUT);

}

void loop(){

delay(2000); // it gives you time to open the serial monitor after you upload the sketch

if (done==false){ // it only runs the loop once

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

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

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

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

done=true;

}

}

error: no matching function for call to 'SharpIR::SharpIR(const uint8_t&, int,Is that the complete error message ?

You have been told before to use code tags :wink:

sketch_mar29c:7: error: no matching function for call to 'SharpIR::SharpIR(const uint8_t&, int, int, int)'

SharpIR rangeSensor( RANGE_SENSOR_PIN, 25, 93, 1080 );

^

C:\Users\Gabri\Documents\Arduino\sketch_mar29c\sketch_mar29c.ino:7:53: note: candidates are:

In file included from C:\Users\Gabri\Documents\Arduino\sketch_mar29c\sketch_mar29c.ino:1:0:

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:29:5: note: SharpIR::SharpIR(uint8_t, uint8_t)

SharpIR(uint8_t _sensorType, uint8_t _sensorPin);

^

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:29:5: note: candidate expects 2 arguments, 4 provided

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:25:7: note: constexpr SharpIR::SharpIR(const SharpIR&)

class SharpIR

^

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:25:7: note: candidate expects 1 argument, 4 provided

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:25:7: note: constexpr SharpIR::SharpIR(SharpIR&&)

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:25:7: note: candidate expects 1 argument, 4 provided

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h: In function 'void loop()':

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:40:13: error: 'uint8_t SharpIR::distance' is private

uint8_t distance;

^

sketch_mar29c:17: error: within this context

Serial.println( rangeSensor.distance() );

^

sketch_mar29c:17: error: expression cannot be used as a function

Serial.println( rangeSensor.distance() );

^

exit status 1
no matching function for call to 'SharpIR::SharpIR(const uint8_t&, int, int, int)'

Still/again, code tags :wink:

sketch_mar29c:7: error: no matching function for call to 'SharpIR::SharpIR(const uint8_t&, int, int, int)'

SharpIR rangeSensor( RANGE_SENSOR_PIN, 25, 93, 1080 );

^

C:\Users\Gabri\Documents\Arduino\sketch_mar29c\sketch_mar29c.ino:7:53: note: candidates are:

In file included from C:\Users\Gabri\Documents\Arduino\sketch_mar29c\sketch_mar29c.ino:1:0:

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:29:5: note: SharpIR::SharpIR(uint8_t, uint8_t)

SharpIR(uint8_t _sensorType, uint8_t _sensorPin);

^

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:29:5: note: candidate expects 2 arguments, 4 provided

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:25:7: note: constexpr SharpIR::SharpIR(const SharpIR&)

class SharpIR

^

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:25:7: note: candidate expects 1 argument, 4 provided

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:25:7: note: constexpr SharpIR::SharpIR(SharpIR&&)

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:25:7: note: candidate expects 1 argument, 4 provided

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h: In function 'void loop()':

C:\Users\Gabri\Documents\Arduino\libraries\SharpIR\src/SharpIR.h:40:13: error: 'uint8_t SharpIR::distance' is private

uint8_t distance;

^

sketch_mar29c:17: error: within this context

Serial.println( rangeSensor.distance() );

^

sketch_mar29c:17: error: expression cannot be used as a function

Serial.println( rangeSensor.distance() );

^

exit status 1
no matching function for call to 'SharpIR::SharpIR(const uint8_t&, int, int, int)'

[quote/]

See reply #4

It's you who wants free answers/help, isn't it? Then the least you can do is simply make our life easier and follow the very simple forum rules. Code tags just make it so much easier to handle the code :slight_smile: And if you think we are picky, let me tell you, a compiler is even more picky!

[edit]Was in reply of a rude comment[/edit]

@gabrielislost is currently enjoying a brief forum timeout.

Hopefully @gabrielislost will use this time productively to read the forum rules and guidelines which some of the "stupid people" and "f***ing losers" here on the forum have taken the time to write, to help you to help them to solve your problems.