xbee series 2 and arduino mega communication issues.

hello I'm trying to communicate between arduino mega+ shield and xbee 2. message from seriel monitor is visible xctu, but the reverse communication is not happening. I tried all that I could as a beginner. please help!!!!!!!!

code:

SoftwareSerial XBee(2,3); // RX, TX

void setup() { . XBee.begin(9600); Serial1.begin(9600); }

void loop() { if (Serial1.available()) { // If data comes in from serial monitor, send it out to XBee XBee.write(Serial.read()); } if (XBee.available()) { // If data comes in from XBee, send it out to serial monitor Serial1.write(XBee.read()); } }

Shouldn't this:

  if (Serial1.available())
  { // If data comes in from serial monitor, send it out to XBee
    XBee.write(Serial.read());
  }

be

  if (Serial1.available())
  { // If data comes in from serial monitor, send it out to XBee
    XBee.write(Serial1.read());
  }

i.e you've missed the 1 off Serial1