bytes to int?

i have a project where im sending data 1-10 from one xbee to another when i send 1 it gets recieved as 49 that i now know is the number of bytes but when i send 10 it comes as 49.48.49.48......and confuses my reciever how can i convert this on ether side to come as 10?

49.48.49.48

Those are the ASCII code values for the characters ‘1’, ‘0’, ‘1’, ‘0’.

Please post your program. Use code tags (the </> button on the toolbar).

it gets recieved as 49 that i now know is the number of bytes

I doubt it. It's more likely that it's the ASCII code for a 1. Try subtracting 48 (or '0') from the number that you receive and it may make more sense.

hers my xbee router side code first then the cordinator both are in at mode

#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 12); // RX, TX

const int SW1 = 8; //forward
const int SW2 = 9; //backward
const int SW3 = 3; //left
const int SW4 = 2; //right
void setup()
{
  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)
{
  byte data = 0;
  if (digitalRead(SW1) == HIGH)
  {
    data += 1;
  }
  if (digitalRead(SW2) == HIGH)
  {
    data += 2;
  }
  if (digitalRead(SW3) == HIGH)
  {
    data += 4;
  }
  if (digitalRead(SW4) == HIGH)
  {
    data += 8;
  }
  if(data > 0)
  {
    delay(50);
  mySerial.print(data);
 Serial.print(data);
  }
data -= data;
}
#include <MotorDriver.h>
byte data = 0;
void setup()
{
  motordriver.init();
  motordriver.setSpeed(250, MOTORB);
  motordriver.setSpeed(250, MOTORA); // steering motor

  Serial.begin(9600);
}
void loop()
{
  if (Serial.available() > 0)
  {
    data = Serial.read()-'0';
  }
  if (data == 1)
  {
    motordriver.goForward();
  }
  else if (data == 2)
  {
    motordriver.goBackward();
  }
  else if (data == 4)
  {
    motordriver.goLeft();
  }
  else if (data == 8)
  {
    motordriver.goRight();
  }
  else if (data == 5)
  {
    motordriver.goForward();
    motordriver.goLeft();
  }
  else if (data == 9)
  {
    motordriver.goForward();
    motordriver.goRight();
  }
  else if (data == 6)
  {
    motordriver.goBackward();
    motordriver.goLeft();
  }
  else if (data == 10)
  {
    motordriver.goBackward();
    motordriver.goRight();
  }
  else
  {
    motordriver.stop();
  }
  delay(50);
  if (data > 0)
  {
    Serial.print("data=");
    Serial.println(data, DEC);
  }
  data -= data;

}

ignore the data -= data in the first code i removed that after post

also i added the -'0' to convert it back to 1-9 but still dont know how to do the 10

In the sending code, you declare data as a byte (unsigned 8-bit integer) and then set various bits.

When you transmit it, use write instead of print:

mySerial.write(data);

The write method sends a byte "as is". The print method treats data as a value that you want to display for a human to read. So it converts it to ASCII characters: "1" ... "10".

In your receive program, you do not need the subtraction:

data = Serial.read();

Then your comparisons in the if statement should work.

now its converting 1 to 209

my bad forgot to take out the -'0' thanks alot !!