Skip to main content
Arduino

Return to Question

Commonmark migration
Source Link

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. [![enter image description here][1]][1]enter image description here

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? [1]: https://i.sstatic.net/UyKUE.jpg

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. [![enter image description here][1]][1]

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? [1]: https://i.sstatic.net/UyKUE.jpg

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. enter image description here

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?

Source Link
Calco
  • 163
  • 1
  • 1
  • 11

Communicating Via Serial1 on Arduino Mega

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. [![enter image description here][1]][1]

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? [1]: https://i.sstatic.net/UyKUE.jpg

AltStyle によって変換されたページ (->オリジナル) /