SoftwareSerial mySerial = SoftwareSerial(2, 13);
mySerial.begin(9600); // Setup Serial library at 9600 bps
I thought this is what allowed me to use pins 2,13 for the RX & TX?
You have to move some wires. Unless you are using a shield to connect the XBee, in which case you probably can't use pins 2 and 13.
I am physically moving the wires from headers 0,1 to the headers marked 2,13. The shield I am using does not have a need foe these two pins, therefore I am going to wire the XBee directly through these headers by way of the shields headers. (It was a motor shield that I have slightly customized to suit this project)
Use a meaningful name!
Can I name it anything I want? I was thinking this name was referenced somewhere in the library... No I haven't opened it and looked...
The SoftwareSerial instance is local to setup(). When setup() ends, the variable goes out of scope. You won't be able to use it in loop(). Sort of makes it useless, don't you think? A global instance would be a lot more useful.
Ah, a global instance sounds good but I am unsure how to declare it, so I declared the scope the same way that Serial is normally declared. I thought you said;
instance can go before or after that BLOCK of code
I was kind of using this old code from Adafruit as an example to set new pins to read RX / TX, it still uses the "NewSoftSerial".
#include <NewSoftSerial.h>
NewSoftSerial mySerial = NewSoftSerial(2, 3);
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop() // run over and over again
{
if (mySerial.available()) {
Serial.print((char)mySerial.read());
}
if (Serial.available()) {
mySerial.print((char)Serial.read());
}
delay(100);
}
Thanks =)