How do I combine a variable and characters into a string with Arduino? I am building some sensors with Arduinos, which each have a unique integer address from 1-9 (This address is an int variable stored in a struct 'Matrix', the variable name is Matrix.Address). The sensors will all be connected to a PLC via SoftwareSerial (BitBanging) through an RS232 converter. Since all of the Sensors will be connected to the same RX &amp; TX ports on the PLC, I need a way to address each sensor through a unique string.

My plan is the following:

*If the PLC wants a reading from sensor #1, it will send the string: "1,read"
All of the sensors should receive this string, but I only want the sensor with address '1' to respond.

*What I am trying to do is come up with a line of code similar to the following:

    if (plcCommand == (Matrix.Address + ",read&lt;CR&gt;")) {
  mySerial.print(GenerateEquation());


Basically, I need to insert that 'Matrix.Address' variable into a string which will be compared to the incoming string.

It seems like a very simple thing to do, but I am having trouble coming up with a solution.

Any help would be appreciated!
You're thinking backwards. Instead of building up one string and comparing it to another, you should instead be splitting down the string you are being sent and dealing with the different parts of it separately.

Say you are being sent the string 32,read\r. Instead of making another string 32,read\r and comparing it to what you have received you should instead be splitting the incoming string up. 

That way you then have a string containing 32 which can be converted to an integer, and a string containing read. It now becomes very simple to do your comparisons without messing with building strings in RAM wasting precious memory.