Unable to Serial.read() using Arduino and XBee

Hi everyone.

I am developing a program in which I use an Arduino MEGA and a Wireless Proto Shield with an XBee mounted (API2).In the program I am working on I create a kind of ‘menu’ with different options, which is shown by the Serial. Once displayed, I choose one of those options and with a switch the program would be developed:

CODE:

#include

int option;

void setup() {
Serial.begin(9600);
xbee.setSerial(Serial);

Serial.print("- MENU -
");
Serial.print("1: Encontrar/Actualizar dispositivos
");
Serial.print("2: Encender dispositivo
");
Serial.print("3: Apagar dispositivo
");
Serial.print("Introduzca opcion: ");
}

void loop() {

if(Serial.available()>0){
option=Serial.read()-48;
Serial.print(option);

switch(option){
  case 1:
    Serial.print("

-NODE DISCOVERY-

");
NodeDiscovery();
break;

  case 2:
   
}

}

}


The problem is when using an XBee. When mounted, the Serial.read () doesn’t work for me. That is, it does not display Serial.print (option) or enter the switch. It does not work.
However, when removing the XBee, I can already type an option through the Serial, it recognizes it and shows me what is inside the switch.

I do not know why, if the XBee interferes in any way or if I would have to proceed in another way to use the serial.
I would appreciate any advice. Thank you.

Antonio,

This is something you really need to address on a Arduino forum.