cheng280186610
耶路撒冷与小呢你
2021-07-17 11:50
采纳率: 0%
浏览 219

关于Arduino的LobotServoController报错的问题

#include <SoftwareSerial.h>
#include <LobotServoController.h> /*舵机控制板二次开发头文件*/
#define TX  7          /*连接摄像头OpemMV的引脚TX 7号IO*/
#define RX  6          /*连接摄像头OpemMV的引脚RX 6号IO*/
#define rxPin 11
#define txPin 10

SoftwareSerial MySerial(rxPin, txPin);
LobotServoController Controller(MySerial);  //实例化舵机控制板二次开发类,使用1号串口作为通信接口
String code = "";
int i;

SoftwareSerial OpenmvSerial(RX, TX);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  MySerial.begin(9600);
  OpenmvSerial.begin(115200); //初始化软串
  Controller.runActionGroup(0, 1); //执行0号动作组
  delay(1000);
  Controller.stopActionGroup();         //停止动作组
}

void loop() {
  // put your main code here, to run repeatedly:
  String code = "";
  while (OpenmvSerial.available() > 0)
  {
    code += char(OpenmvSerial.read());
  }
  if (code.length() > 0) 
  {
    Serial.write("OpenMV Code:");
    Serial.println(code);
    Serial.write("\n");
    if (code != "l" && code != "r")
    {
      Controller.runActionGroup(1, 1); //执行1号动作组
    }
    if (code == "l")
    {
      Controller.runActionGroup(34, 1); //执行34号动作组
    }
    if (code == "r")
    {
      Controller.runActionGroup(35, 1); //执行35号动作组
    }
  }
}

我在Arduino上编译巡线的程序,结果现在出现了问题,主要原因在
LobotServoController Controller(MySerial); //实例化舵机控制板二次开发类,使用1号串口作为通信接口
这一行上
错误信息有:
sketch_jul17a:9: error: no matching function for call to 'LobotServoController::LobotServoController(SoftwareSerial&)'

Arduino:1.6.11 (Windows 10), 开发板:"Arduino Nano, ATmega328"

构建选项已变更,全部重新构建
sketch_jul17a:9: error: no matching function for call to 'LobotServoController::LobotServoController(SoftwareSerial&)'

D:\BaiduNetdiskDownload\涓浗鏈哄櫒浜哄ぇ璧沑Arduino渚嬬▼\sketch_jul17a\sketch_jul17a.ino:9:41: note: candidates are:

In file included from D:\BaiduNetdiskDownload\涓浗鏈哄櫒浜哄ぇ璧沑Arduino渚嬬▼\sketch_jul17a\sketch_jul17a.ino:2:0:

C:\Users\89212\Documents\Arduino\libraries\LobotServoController/LobotServoController.h:35:5: note: LobotServoController::LobotServoController(HardwareSerial&)

     LobotServoController(HardwareSerial &A);

     ^

C:\Users\89212\Documents\Arduino\libraries\LobotServoController/LobotServoController.h:35:5: note:   no known conversion for argument 1 from 'SoftwareSerial' to 'HardwareSerial&'

C:\Users\89212\Documents\Arduino\libraries\LobotServoController/LobotServoController.h:34:5: note: LobotServoController::LobotServoController()

     LobotServoController();

     ^

C:\Users\89212\Documents\Arduino\libraries\LobotServoController/LobotServoController.h:34:5: note:   candidate expects 0 arguments, 1 provided

C:\Users\89212\Documents\Arduino\libraries\LobotServoController/LobotServoController.h:32:7: note: constexpr LobotServoController::LobotServoController(const LobotServoController&)

 class LobotServoController {

       ^

C:\Users\89212\Documents\Arduino\libraries\LobotServoController/LobotServoController.h:32:7: note:   no known conversion for argument 1 from 'SoftwareSerial' to 'const LobotServoController&'

exit status 1
no matching function for call to 'LobotServoController::LobotServoController(SoftwareSerial&)'

在文件 -> 首选项开启
“编译过程中显示详细输出”选项
这份报告会包含更多信息。


重装Arduino还是其他的,都无法解决问题,也不知道是不是库文件的问题

  • 点赞
  • 收藏

3条回答 默认 最新

  • soar3033
    soar3033 2021-07-18 09:36

    不要用软串口,不要用软串口,不要用软串口
    如果用软串口就不要用LobotServoController Controller
    参见这个https://blog.csdn.net/u014624241/article/details/83239414

    点赞 1 评论
  • cheng280186610
    耶路撒冷与小呢你 2021-07-17 22:43

    啊啊啊,就没人吗,麻烦大佬们看一下啊

    点赞 评论
  • Feng_wwf
    NDSC专家-王文峯 2021-07-19 10:40

    看一下Arduino常见报错汇总 ,望采纳,谢谢

    http://www.alsrobot.cn/wiki/index.php/Arduino常见报错汇总

    点赞 评论

相关推荐