crown
February 4, 2013, 7:38am
1
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.
crown
February 4, 2013, 5:38pm
3
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.
waltr
February 4, 2013, 7:08pm
4
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).
crown
February 4, 2013, 8:23pm
5
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 )
crown
February 4, 2013, 8:52pm
6
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.
waltr
February 5, 2013, 1:06am
7
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.
stevech
February 13, 2013, 4:10am
9
single/double quotes is a C thing. Some other languages like JavaScript and Python treat them as equals.