Home/Support/Support Forum/Unable to Serial.read() using Arduino and XBee

Unable to Serial.read() using Arduino and XBee

0 votes
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 <XBee.h>

int option;

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

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


void loop() {

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

switch(option){
case 1:
Serial.print("\n\n-NODE DISCOVERY-\n\n");
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.
asked Jun 25 in XBee Programmable Development by AntonioGR96 New to the Community (1 point)
edited Jun 25 by mvut

Please log in or register to answer this question.

1 Answer

0 votes
Antonio,

This is something you really need to address on a Arduino forum.
answered Jun 29 by mvut Veteran of the Digi Community (13,406 points)
...