I am trying to send a string from one mega to the other and have done so doing this:
void setup() {
// initialize both serial ports:
Serial.begin(9600);
Serial1.begin(9600);
}
void loop()
{
Serial1.write("0;200;");
delay(2000);
}
That works great. Now I wanted to build up my string before I sent it. So I took it the next step further and tried saving that same string into a variable and the send the variable, like this:
void setup() {
// initialize both serial ports:
Serial.begin(9600);
Serial1.begin(9600);
}
void loop()
{
String boss = "0;200;";
Serial1.write(boss);
delay(2000);
}
This seems like it would work perfectly fine(or else it did to me) but I am getting this error: "no matching function for call to 'HardwareSerial::write(String&)' "
Not sure why this error is happening because I am sending the same string. Any help would be appreciated. If someone has a better way to send a string than a "Serial1.write()" command I am all ears for that as well.
Thanks in advance