XBee sends different data than gets received ??

Arduino micro with xbee pro 256 as router sending data to mega with motor shield, xbee shield and another xbee pro 256 as cordinator.
i have it adding the data to be sent on the tx side 1+2+4+8…forward,backward,left,right…

on the mega or the rx side the data comes as
1=49
2=50
4=52
8=56
and so on…is there any reason why it would convert this? also 10 (8+2) wich is my backward turn right command comes across as 48,49,48,49…and it should be a constant 59 if it fallows the current pattern anyway. ill post micro router code first then mega

#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 12); // RX, TX
//BUTTON PINS
const int SW1 = 8; //forward
const int SW2 = 9; //backward
const int SW3 = 3; //left
const int SW4 = 2; //right
void setup()
{
  //SET BUTTON AS PULLUP
  pinMode(SW1, INPUT_PULLUP);
  pinMode(SW2, INPUT_PULLUP);
  pinMode(SW3, INPUT_PULLUP);
  pinMode(SW4, INPUT_PULLUP);
  //pinMode(Light, INPUT);
  Serial.begin(9600);
mySerial.begin(9600);
}

void loop(void)
{
  int data = 0;
  
  //Forward
  if (digitalRead(SW1) == HIGH)
  {
    data += 1;
  }
  //Backward
  if (digitalRead(SW2) == HIGH)
  {
    data += 2;
  }
  //left
  if (digitalRead(SW3) == HIGH)
  {
    data += 4;
  }
  //right
  if (digitalRead(SW4) == HIGH)
  {
    data += 8;
  }
  if(data > 0)
  {
    delay(50);
  mySerial.print(data);
 Serial.print(data);
  }

}
#include <MotorDriver.h>
int data = 0;
void setup()
{
  //MOTOR SHIELD SET MOTOR SPEEDS
  motordriver.init();
  motordriver.setSpeed(250, MOTORB);
  motordriver.setSpeed(250, MOTORA); // steering motor
  //BEGIN SERIAL COMMUNICATION
  Serial.begin(9600);
}
void loop()
{
  if(Serial.available())
  {
data = Serial.read();
  }
  //DATA FROM TRANSMITTER TO DETERMINE MOVE FUNCTION
  // move forward
  if (data == 49)
  {
    motordriver.goForward();
    
  }
  //move backward
  else if (data == 50)
  {
    motordriver.goBackward();
    
  }
  else if (data == 52)
  {
    motordriver.goLeft();
    
  }
  else if (data == 56)
  {
    motordriver.goRight();
    
  }
  //straight left turn
  else if (data == 53)
  {
    motordriver.goForward();
    motordriver.goLeft();
    
  }
  //straight right turn
  else if (data == 57)
  {
    motordriver.goForward();
    motordriver.goRight();
    
  }
  //back left turn
  else if (data == 54)
  {
    motordriver.goBackward();
    motordriver.goLeft();
   
  }
  //back right turn
  else if (data == 48)
  {
    motordriver.goBackward();
    motordriver.goRight();
    
  }
  else 
  {
   motordriver.stop(); 
  }
  //SERIAL PRINT DATA RECIEVED
  delay(50);
  if (data > 0)
  {
  Serial.print("data=");
  Serial.println(data, DEC);
  }
  data -= data;

}

both are in AT mode

it turns out my xbee has a max byte of 54 so 1=49 bytes? then 10 abviously is more then that so its sending the 1(49bytes) and then 0 (48bytes) makes sense why its 48,49,48,49......how can i conver this on ethear end so that the right number is being sent/received?

serial.print() will send the ASCII codes for the digits of the number.

0 is ASCII code 48, 1 is 49,...

also it will send one byte at a time and your serial.read() is going to pick up 1 byte at a time.

Suggestion googling and reading up on serial.print and read

hope this helps.

Somebody else had the same problem earlier today on the forum. Worth a look.

http://forum.arduino.cc/index.php?topic=332123.msg2291629#msg2291629