Let's Make Robots!

Sending string via XBee and

I am sending string from Arduino to Arduino via Xbee. I don't know if this is the proper way to do it and I am open to know any feedbacks. Here is what I do, I am sending something from A and  it looks like:


Now, B is getting this string and trying to analyze it. Here is my code:


  if (Serial.available() > 0) {

    char incomingString = Serial.read();




It doesn't read the string but some single character. The line "char incomingByte = Serial.read();" should be the problem and I am not sure what is *sign for. Please help if anyone knows how to do this? Thanks a lot!


I use this function to break the string into variable I need.

char* subStr (char* str, char *delim, int index) {

   char *act, *sub, *ptr;

   static char copy[MAX_STRING_LEN];

   int i;

   strcpy(copy, str);

   for (i = 1, act = copy; i <= index; i++, act = NULL) {


sub = strtok_r(act, delim, &ptr);

if (sub == NULL) break;


   return sub;


And this always works while testing:

     Serial.println(subStr(incomingByte, "|", 1));

     Serial.println(subStr(incomingByte, "|", 2));

     Serial.println(subStr(incomingByte, "|", 3)); // and so on

It breaks to string into what I need.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi patrick, thansk for the link. Yes it works. However, i don't know if thats the way it works for having about 0.5~1 sec delay?

I have post it on youtube here:http://www.youtube.com/watch?v=z-fehe8BQgE

Let me know how do you think. Thanks~

Can you post your code you are using now on the transmitting and recieving end?

It's the standard code that you download with. Didn't changed anything.

EasyTransfer v1.1

Well the original code does not use LED strips and does not light up something on the TX side. So I am just wondering if what you added, plus the fact that it is sending random data is what is causing the delay.

Any way you can just setup a button that when pushed lights up the LED strip on the other Arduino? Something that simple would get rid of the other factors. 

Got it. Because of the delay time. It was delay(2500), so it could be anytime in between 0~2500ms I think. I shorten it to 500 and it's reacting much faster.

One more thing I always wondering; if I have delay(10) which is almost in real time. Does it effect anything? like decrease the performance or power consumption or anything else?

Thanks for your help~~

I'm sorry --I was looking at the code and thinking Processing. Sorry, this is arduino to arduino...

Yeah, listen to Pat.

You might find this helpful http://letsmakerobots.com/node/27108

I think split string is what you might want.


Idk if this can be used in the Arduino language