AltSoftSerial SoftSerial;

I have a question about this statement: AltSoftSerial SoftSerial;

Here is the very start of the program SerialDump:

#include <AltSoftSerial.h>


// Use some macros to allow changing the serial ports to use easily

AltSoftSerial SoftSerial;

#define DebugSerial Serial
#define XBeeSerial SoftSerial


What is the "AltSoftSerial SoftSerial;" statement doing and how does it affect #define XBeeSerial SoftSerial in the last line.

I know that I am changing the variable XBeeSerial to SoftSerial in the body of the program, so what's the function of "AltSoftSerial SoftSerial;"

Thanks

John

AltSoftSerial SoftSerial;

SoftSerial is an object of the AlfSoftSerial libraby. For more info, read here: Classes amd Objects

#define XBeeSerial SoftSerial

This line tell the compiler to replace "XbeeSerial" by "SoftSerial" everywhere in code. So basically, "XbeeSerial" is just another name for "SoftSerial", they are the same thing.

arduino_new:

#define XBeeSerial SoftSerial

This line tell the compiler to replace "XbeeSerial" by "SoftSerial" everywhere in code. So basically, "XbeeSerial" is just another name for "SoftSerial", they are the same thing.

The thing to remember is that #defines are like find/replace, which can have surprising consequences if you were expecting something else.