1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Corretions and refinements to the String examples

This commit is contained in:
Federico Vanzati
2012-04-06 12:59:54 +02:00
parent ade4893f58
commit 383ac95f3e
1111 changed files with 244427 additions and 223 deletions

View File

@ -17,7 +17,7 @@ void setup() {
Serial.begin(9600);
// this check is only needed on the Leonardo:
while (!Serial) ;
;
;
Serial.println("\n\nString charAt() and setCharAt():");
}
@ -26,18 +26,19 @@ void loop() {
// make a string to report a sensor reading:
String reportString = "SensorReading: 456";
Serial.println(reportString);
// the reading's most significant digit is at position 15 in the reportString:
String mostSignificantDigit = reportString.charAt(15);
char mostSignificantDigit = reportString.charAt(15);
Serial.println("Most significant digit of the sensor reading is: " + mostSignificantDigit);
// add blank space:
// add blank space:
Serial.println();
// you can alo set the character of a string. Change the : to a = character
reportString.setCharAt(13, '=');
Serial.println(reportString);
// do nothing while true:
while(true);
}
}