Arduino + XBee output

I have an Arduino with an attached Xbee talking to another Xbee, which is attached to my computer. The Arduino is programmed to be very simple right now and only implements this loop:

Serial.write(‘test’);

Serial.write(‘\t’);

The output is “t.” looped (without the quotes). When I tried doing

Serial.print(‘test’);

Serial.write(‘\t’);

I instead got “29556.” (looped).

I’m not really sure why this is. Why are the characters not being transmitted as is?

What version of the IDE are you using?

Post your entire code in code tags. There maybe something else going on.

For the arduino, my code is:

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

void loop(){
  Serial.print('test');
  Serial.write('\t');
}

For the XBee, I’m just listening and there is no code implemented.

Have you gotten the Arduino ‘talking’ to your PC without the XBees?

This should be the first step and separates issues with Aduino code verse XBee setup.

You could try adding a delay after writing the ‘t/’ to the serial port, about 1sec would be good.

Exactly which XBees module do you have?

What is the Firmware version is the XBees? (Use X-CTU to read the version).

So I found that if I changed the ‘test’ to a “test”, then it works. Is the single character quote special in some way?

(I also ran across this same problem: http://stackoverflow.com/questions/1128 … rial-print)

Ahh, I see now. Anything in single quotes is considered a char and stored as a number, while anything in double quotes is considered a string.

Good catch, I missed that.

crown:
Ahh, I see now. Anything in single quotes is considered a char and stored as a number, while anything in double quotes is considered a string.

Thanks for the tip - I didn't pay attention to it.

single/double quotes is a C thing. Some other languages like JavaScript and Python treat them as equals.