Just as you can concatenate Strings with other data objects using the StringAdditionOperator, you can also use the
+=
operator and the concat()
method to append things to Strings. The +=
operator and the concat()
method work the same way, it's just a matter of which style you prefer. The two examples below illustrate both, and result in the same String:1String stringOne = "A long integer: ";2// using += to add a long variable to a string:3stringOne += 123456789;
or
1String stringTwo = "A long integer: ";2// using concat() to add a long variable to a string:3stringTwo.concat(123456789);
In both cases,
stringOne
equals "A long integer: 123456789". Like the +
operator, these operators are handy for assembling longer strings from a combination of data objects.There is no circuit for this example, though your board must be connected to your computer via USB and the serial monitor window of the Arduino Software (IDE) should be open.
You can find more basic tutorials in the built-in examples section.
You can also explore the language reference, a detailed collection of the Arduino programming language.
Last revision 2015/08/11 by SM