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:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user