Help Required! Problem in receiving multilple PWM's value using XBEE(series 1)

Hi.I am using two XBEE’s (series 1) in AT mode…i attached my one xbee with laptop and sending multiple PWM’s values by making array…and receiving those PWM’s values using another XBEE on arduino side by making array also.I give those PWM’s values directly to my motors…
The probelm is that,Since there is no start and stop bits in AT mode. Therefore my receiving PWM’s values are not going to their corresponding motors i.e one PWM go to other and so on…So i want to add start and stop bit in my code so receiving PWM’s go to their corresponding motors…
Here is my code.

void loop()
  while (Serial.available() > 0)
  byte inByte[4];//four motors pwm's
    for(int i = 0; i < 4; i++)
      inByte[i] =;
      delay(17);// without delay it will give faulty readings...because Array will not fill properly...
   PWM1_val = inByte[0] ; //PWM1_val defined in void setup().
   PWM2_val = inByte[1];  //PWM2_val defined in void setup()
   PWM3_val = inByte[2];  //PWM3_val defined in void setup()
   PWM4_val = inByte[3];  //PWM4_val defined in void setup()
    digitalWrite(InA1, HIGH);
    digitalWrite(InB1, LOW);
    analogWrite(PWM1, PWM1_val);
    digitalWrite(InA2, HIGH);
    digitalWrite(InB2, LOW);
    analogWrite(PWM2, PWM2_val);
    digitalWrite(InA3, LOW);
    digitalWrite(InB3, LOW);
    analogWrite(PWM3, PWM3_val);
    digitalWrite(InA4, LOW);
    digitalWrite(InB4, LOW);
    analogWrite(PWM4, PWM4_val);

I think you are saying you want to add some data synchronization, this isnt really the same as start and stop bits as those are technically sent as part of each byte depending on what format you send the RS232, and won't help with this

there are lots of ways to do this e.g. do you need the full range of numbers 0 to 255 or could you simply never use 01 as motor speed. in which case send 01, then your data of 4 bytes, and in your code you just wait for an 01 which you know is never real data

Or another way to do this is to send 1 byte containing the motor number followed by the next byte containing the motor value


01 AA 02 BB 03 CC 04 DD

Then in your code you need to look for a sequence that seems to be valid, i.e if you read 01 skip 1 and the next is 02 skip 1 and the next if 03 skip 1 and the next is 04, I'd say that the chances are that you have synchronized the data.

But if you use this sort of option, its not guaranteed that the byes AA BB CC and DD don't contain 01 02 03 04 as their values