serial print to xbee

Hi! I have a problem when using xbee between my computer and my arduino.

I have a loop that looks for serial input, and if available it reads it and use the command to give a reply. If i have this string in the bottom of the loop: Serial.println(); everything works fine. It looks for commands and gives reply.

BUT, if I remove the code in the bottom, so I only get a serial reply when I want to, nothing works.

Anyone here have an idea?

Here is my test code:

int command = 0;

void setup()
{
  Serial.begin(57600);
}

void loop(){
  if (Serial.available())
  {
    command = Serial.read();
    if (command == 84)
    {
      Serial.println("You pressed T");
    }
    else if (command == 71)
    {
      Serial.println("You pressed G");
    }
  Serial.print("Command: ");
  Serial.println(command);
  }
  Serial.println();           //<----------- Nothing works without this line
  command = 0;
  delay(500);
}
    if (command == 84)
    {
      Serial.println("You pressed T");
    }
    else if (command == 71)
    {
      Serial.println("You pressed G");
    }

You know, it really isn’t necessary to look up the ASCII values of letters. The compiler already knows the values.

if(command == 'T')

works just as well, and even I can figure out what letter to send to get the response.

  Serial.println();           //<----------- Nothing works without this line

Then, you need to tell us what is on the other end of the serial port. The Serial Monitor does not require that statement.

My arduino is connected to a xbee breakout board wich have a xbee pro s2. This is configured as a router/end device AT.

This is in a network with a xbee pro s2 that stands in a usb explorer.

I use terminal in x-ctu on a windows pc to communicate with it

I use terminal in x-ctu on a windows pc to communicate with it

Then, what was the question?

if you read the first post, you can find it

If you open the Serial Monitor, can you dispense with the unnecessary Serial.println()? If so, then the issue is with X-CTU.

What other program can i use to test it?

What other program can i use to test it?

Why not use the Serial Monitor?

ok. can I use serial monitor with xbee? I didnt know.. will try it.. thanx;)