C:\Users\qianc\Documents\Arduino\sketch_may30a_servo\sketch_may30a_servo.ino: In function 'void loop()': C:\Users\qianc\Documents\Arduino\sketch_may30a_servo\sketch_may30a_servo.ino:23:28: error: no matching function for call to 'Servo::write(float&, int)' myservo0.write(msg, 300); // 控制舵机转动到指定角度 ^ In file included from C:\Users\qianc\Documents\Arduino\sketch_may30a_servo\sketch_may30a_servo.ino:1:0: C:\Users\qianc\AppData\Local\Arduino15\libraries\Servo\src/Servo.h:111:8: note: candidate: void Servo::write(int) void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds ^~~~~ C:\Users\qianc\AppData\Local\Arduino15\libraries\Servo\src/Servo.h:111:8: note: candidate expects 1 argument, 2 provided exit status 1 Compilation error: no matching function for call to 'Servo::write(float&, int)'是什么意思
时间: 2023-07-20 19:22:11 浏览: 118
这个错误提示是因为`Servo`库中的`write()`函数只接受一个整数型参数,而你的代码中传递了一个浮点型参数和一个整数型参数。因此,编译器无法匹配到适合的函数。
你需要将`msg`参数转换为整数型后再传递给`write()`函数。例如,你可以使用`int()`函数将`msg`转换为整数型,如下所示:
```
myservo0.write(int(msg), 300); // 控制舵机转动到指定角度
```
这样就可以避免这个错误了。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pptx](https://img-home.csdnimg.cn/images/20241231044947.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)