Receiving Strings

Is there a way to convert integers into strings? I have two xbees and one is sending text over to the other. But when I use xbee.read and display it on an LCD all I get is numbers. I tried storing the number in an int variable and changing it to a char variable but I am getting characters from an Asian alphabet. Or can someone suggest a better way of accomplishing this? I am using AT mode as an FYI.

void setup() {
  Serial.begin(9600);
  XBee.begin(9600);
  
  String h = "Waiting For Play";
  // set up the LCD's number of rows and columns:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print(h);
  
}

void loop() {
 if (XBee.available())
  {
    int a =  XBee.read();
    char b = a;
    
    lcd.print(b);

  }
}

all I get is numbers.

Are the numbers by any chance the ASCII codes for the characters ?

Is the transmitter sending numbers or characters ?

It is transmitting letters. Here is example code:

case '0':
      {
        Serial.print("Hook");
        key=0;
      }
    break;

So when I send Hook it comes out as 188157
In the past when I sent individual characters it came out in decimal form so I just converted them. But I can't find the correlation between 188157 and "Hook"

So when I send Hook it comes out as 188157

I'm pretty sure that if you printed the values with spaces between them that you would see what the problem is.

Afterallthatswhywedontjuststreamwordstogetherwhenwewrite.

 if (XBee.available())
  {
    int a =  XBee.read();
    char b = a;

If you want a char, why not just read one?

 if (XBee.available())
  {
    char a =  XBee.read();

@PaulS I tried what you said and I put the spaces between them and got the same values. Then I tried sending one letter at a time and the characters were completely off. For "O" I was getting the division sign (not the slash).

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. I believe the techniques are also appropriate for an XBee.

...R

@Robin2 thank you! However I tried your sample code and it was printing the question marks with other weird characters. Do you know why that is? Your code worked fine I just couldn't see the correct letters.

cder51:
Do you know why that is?

Not without seeing the actual program that you uploaded to your Arduino.

...R

// Example 1 - Receiving single characters

char receivedChar;
boolean newData = false;

void setup() {
    Serial.begin(9600);
    Serial.println("<Arduino is ready>");
}

void loop() {
    recvOneChar();
    showNewData();
}

void recvOneChar() {
    if (Serial.available() > 0) {
        receivedChar = Serial.read();
        newData = true;
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChar);
        newData = false;
    }
}

I am using the Arduino Pro Mini 3.3V

Can you also post an example of what you see in the Serial Monitor?
And also the characters that you sent and which gave rise to that output.

Garbage characters are often due to the wrong baud rate being selected. The Serial Monitor and the Arduino program must both use the same baud rate.

...R

The baud rates were all the same. It's working now but I literally rewrote the code from scratch. Thanks for your help!