下面的代码工作正常没有函数spinLeft()(我从goForward复制并修改).当我尝试添加该功能(稍后使用)时,我得到了上面的错误.但我无法看到我做了什么没有做过的事情.如何添加另一个函数生成此错误?
其余的错误消息说:
Roomba4operants.ino: In function 'void spinLeft()':
Roomba4operants:57: error: call of overloaded 'write(int)' is ambiguous
/Users/royclymer/Desktop/Arduino.app/Contents/Resources/Java/libraries/SoftwareSerial/SoftwareSerial.h:92: note: candidates are: virtual size_t SoftwareSerial::write(uint8_t)
/Users/royclymer/Desktop/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:49: note: size_t Print::write(const char*)
Run Code Online (Sandbox Code Playgroud)
码:
#include <SoftwareSerial.h>
int rxPin = 3;
int txPin = 6;
int ledPin = 13;
SoftwareSerial Roomba(rxPin,txPin);
void setup() {
pinMode(ledPin, OUTPUT); // sets the pins as output
Serial.begin(115200);
Roomba.begin(115200);
digitalWrite(ledPin, HIGH); // say we're alive
Serial.println ("Sending start command...");
delay (1000);
// set up ROI to receive commands
Roomba.write(128); // START
delay(150); …Run Code Online (Sandbox Code Playgroud)