system
April 12, 2012, 8:09pm
1
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?
system
April 12, 2012, 8:16pm
2
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);
}
system
April 12, 2012, 11:02pm
3
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.
system
April 13, 2012, 9:42am
4
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
system
April 14, 2012, 12:46am
5
I use terminal in x-ctu on a windows pc to communicate with it
Then, what was the question?
system
April 14, 2012, 7:48pm
6
if you read the first post, you can find it
system
April 14, 2012, 9:50pm
7
If you open the Serial Monitor, can you dispense with the unnecessary Serial.println()? If so, then the issue is with X-CTU.
system
April 15, 2012, 6:26am
8
What other program can i use to test it?
system
April 15, 2012, 2:07pm
9
What other program can i use to test it?
Why not use the Serial Monitor?
system
April 19, 2012, 2:52pm
10
ok. can I use serial monitor with xbee? I didnt know..
will try it.. thanx;)