Library compatibility


Are arduino uno libraries compatible with arduino mega? I am currently using these two libraries on an arduino uno:

#include <SoftwareSerial.h>
SoftwareSerial XBee(2, 3); // RX, TX

I use this to send and receive data by XBee.

#include <SPI.h>
#include <Ethernet.h>

I use The Arduino Ethernet Shield 2

I want to change this program to arduino mega since I need more pins, can I use these same libraries in the arduino mega?

The MEGA has multiple hardware serial ports, so in general it's a much better idea to use one of those, rather than getting SWserial to work.

That MIGHT be as easy as:

#define Xbee Serial1

Except - note that pins 2/3 on mega are NOT one of the hardware serial ports.