Apologies if this a relatively simple question, but I am rather new to Arduino's and cannot seem to find any concise information on the topic.
This is my XBee, mounted on a shield and placed onto a MEGA 2560. I want to leave Serial for USB debugging and use the Serial1 for XBee communication.
Just to confirm, the two XBee's do communicate if I use SoftwareSerial. This is the code that works using SoftwareSerial:
#include <SoftwareSerial.h>
// XBee's DOUT (TX) is connected to pin 10 (Arduino's Software RX)
// XBee's DIN (RX) is connected to pin 11 (Arduino's Software TX)
SoftwareSerial serial1(10, 11); // RX, TX
boolean nextLine = false;
void setup()
{
Serial.begin(9600);
serial1.begin(9600);
}
void loop()
{
while(serial1.available()){ // there is data being sent from the xBee
char read = char(serial1.read());
if(read == 'A'){
//Where ~ is the EOT character
serial1.write("55.134~");
}
}
}
How do I communicate using Serial1?