// concatenation
// adding a constant integer to a string:
stringThree = stringOne + 123;
// adding a constant long interger to a string:
stringThree = stringOne + 123456789;
// adding a constant character to a string:
stringThree = stringOne + 'A';
// adding a constant string to a string:
stringThree = stringOne + "abc";
// adding two Strings together:
stringThree = stringOne + stringTwo;
////// declare three strings:
String stringOne, stringTwo, stringThree;
stringOne = String("stringThree = ");
stringTwo = String("this string");
stringThree = String ();
// adding a constant integer to a string:
stringThree = stringOne + 123;
Serial.println(stringThree); // prints "stringThree = 123"
// adding a constant character to a string:
stringThree = stringOne + 'A'; // 字元用單引號括起來
Serial.println(stringThree); // prints "You added A"
// adding a constant string to a string:
stringThree = stringOne + "abc"; // 字串用雙引號括起來
Serial.println(stringThree); // prints "You added abc"
// adding a variable integer to a string:
int sensorValue = analogRead(A0);
stringOne = "Sensor value: ";
stringThree = stringOne + sensorValue;
Serial.println(stringThree); // prints "Sensor Value: 401" or whatever value analogRead(A0) has
// adding a variable long integer to a string:
long currentTime = millis();
stringOne="millis() value: ";
stringThree = stringOne + millis();
Serial.println(stringThree); // prints "The millis: 345345" or whatever value currentTime has