首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >意外错误消息,arduino SharpIR

意外错误消息,arduino SharpIR
EN

Stack Overflow用户
提问于 2018-01-17 19:35:07
回答 1查看 165关注 0票数 0

我正在尝试使用GPY2Y0A21Y IRsensor,但我在使代码工作时遇到了问题。我下载了SharpIR,但在使用它的一个函数时遇到了错误。

代码语言:javascript
复制
#include <SharpIR.h>


void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
SharpIR sharp("A1", 25, 93, 1080);
}

void loop() {
  // put your main code here, to run repeatedly:
}

这是错误消息

代码语言:javascript
复制
/var/folders/_z/t_qth0vd0xj6fxvyp_k5nvc00000gn/T/arduino_modified_sketch_475607/sketch_jan17a.ino: In function 'void setup()':
sketch_jan17a:7: error: no matching function for call to 'SharpIR::SharpIR(const char [3], int, int, int)'
 SharpIR sharp("A1", 25, 93, 1080);
                                 ^
/var/folders/_z/t_qth0vd0xj6fxvyp_k5nvc00000gn/T/arduino_modified_sketch_475607/sketch_jan17a.ino:7:33: note: candidates are:
In file included from /var/folders/_z/t_qth0vd0xj6fxvyp_k5nvc00000gn/T/arduino_modified_sketch_475607/sketch_jan17a.ino:1:0:
/Users/jeroenturkstra/Documents/Arduino/libraries/SharpIR/src/SharpIR.h:29:5: note: SharpIR::SharpIR(uint8_t, uint8_t)
     SharpIR(uint8_t _sensorType, uint8_t _sensorPin);
     ^
/Users/jeroenturkstra/Documents/Arduino/libraries/SharpIR/src/SharpIR.h:29:5: note:   candidate expects 2 arguments, 4 provided
/Users/jeroenturkstra/Documents/Arduino/libraries/SharpIR/src/SharpIR.h:25:7: note: constexpr SharpIR::SharpIR(const SharpIR&)
 class SharpIR
       ^
/Users/jeroenturkstra/Documents/Arduino/libraries/SharpIR/src/SharpIR.h:25:7: note:   candidate expects 1 argument, 4 provided
/Users/jeroenturkstra/Documents/Arduino/libraries/SharpIR/src/SharpIR.h:25:7: note: constexpr SharpIR::SharpIR(SharpIR&&)
/Users/jeroenturkstra/Documents/Arduino/libraries/SharpIR/src/SharpIR.h:25:7: note:   candidate expects 1 argument, 4 provided
exit status 1
no matching function for call to 'SharpIR::SharpIR(const char [3], int, int, int)'

我对库之类的东西不是很熟悉,所以我不知道这段代码出了什么问题。我得到的只是这个函数并不存在。我确实下载了SharpIR btw。如果有人能帮上忙,我将不胜感激(本站https://playground.arduino.cc/Main/SharpIR提供了示例代码)

EN

回答 1

Stack Overflow用户

发布于 2018-01-17 19:42:27

SharpIR declaration上看,这个错误似乎是合法的。也许您正在遵循的指南已被弃用,并且与您安装的库不兼容?

代码语言:javascript
复制
class SharpIR
{
  public:

    SharpIR (int irPin, long sensorModel);
    int distance();

  private:

    void sort(int a[], int size);

    int _irPin;
    long _model;
};

对象初始化只需要一个引脚号和一个标识传感器型号的长字符。但是看你问题中的错误,看起来声明是以传感器标识号作为第一个参数,号作为第二个参数来实现的。我认为你真的应该在你的本地安装中打开源代码并检查它。您可以在终端中使用以下命令打印它:

代码语言:javascript
复制
cat /Users/jeroenturkstra/Documents/Arduino/libraries/SharpIR/src/SharpIR.h

(我现在无法打开Dropbox链接...)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48300192

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档