Skip to content

Commit 412f261

Browse files
committed
Corretions and refinements to the String examples
1 parent 200eefb commit 412f261

File tree

20 files changed

+90
-61
lines changed

20 files changed

+90
-61
lines changed

build/linux/work/examples/08.Strings/CharacterAnalysis/CharacterAnalysis.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ void setup() {
1515
// Open serial communications and wait for port to open:
1616
Serial.begin(9600);
1717
// this check is only needed on the Leonardo:
18-
while (!Serial) ;
19-
;
18+
while (!Serial) {
19+
; // wait for serial port to connect. Needed fo Leonardo only
20+
}
2021

2122
// send an intro:
2223
Serial.println("send any byte and I'll tell you everything I can about it");
@@ -81,4 +82,3 @@ void loop() {
8182
Serial.println();
8283
}
8384
}
84-

build/linux/work/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ void setup() {
2020
// initialize serial and wait for port to open:
2121
Serial.begin(9600);
2222
// this check is only needed on the Leonardo:
23-
while (!Serial) ;
24-
;
23+
while (!Serial) {
24+
; // wait for serial port to connect. Needed fo Leonardo only
25+
}
2526

2627
stringOne = String("stringThree = ");
2728
stringTwo = String("this string");
2829
stringThree = String ();
2930
Serial.println("\n\nAdding strings together (concatenation):");
31+
Serial.println();
3032
}
3133

3234
void loop() {

build/linux/work/examples/08.Strings/StringLength/StringLength.ino

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ String txtMsg = ""; // a string for incoming text
1515
int lastStringLength = txtMsg.length(); // previous length of the String
1616

1717
void setup() {
18-
// open the serial port:
18+
// Open serial communications and wait for port to open:
1919
Serial.begin(9600);
20+
// this check is only needed on the Leonardo:
21+
while (!Serial) ;
22+
;
23+
24+
Serial.println("\n\nString length():");
2025
}
2126

2227
void loop() {
@@ -40,4 +45,4 @@ void loop() {
4045
// note the length for next time through the loop:
4146
lastStringLength = txtMsg.length();
4247
}
43-
}
48+
}

build/linux/work/examples/08.Strings/StringLengthTrim/StringLengthTrim.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
*/
1414

1515
void setup() {
16-
// Open serial communications and wait for port to open:
16+
// Open serial communications and wait for port to open:
1717
Serial.begin(9600);
1818
// this check is only needed on the Leonardo:
1919
while (!Serial) ;
20-
;
20+
;
2121

2222
Serial.println("\n\nString length() and trim():");
2323
}

build/linux/work/lib/pde.jar

0 Bytes
Binary file not shown.

build/shared/examples/08.Strings/CharacterAnalysis/CharacterAnalysis.ino

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
void setup() {
1515
// Open serial communications and wait for port to open:
1616
Serial.begin(9600);
17-
// this check is only needed on the Leonardo:
18-
while (!Serial) ;
19-
;
17+
while (!Serial) {
18+
; // wait for serial port to connect. Needed fo Leonardo only
19+
}
2020

2121
// send an intro:
2222
Serial.println("send any byte and I'll tell you everything I can about it");
@@ -81,4 +81,3 @@ void loop() {
8181
Serial.println();
8282
}
8383
}
84-

build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ String stringOne, stringTwo, stringThree;
1919
void setup() {
2020
// initialize serial and wait for port to open:
2121
Serial.begin(9600);
22-
// this check is only needed on the Leonardo:
23-
while (!Serial) ;
24-
;
22+
while (!Serial) {
23+
; // wait for serial port to connect. Needed for Leonardo only
24+
}
2525

2626
stringOne = String("stringThree = ");
2727
stringTwo = String("this string");
2828
stringThree = String ();
29+
// send an intro:
2930
Serial.println("\n\nAdding strings together (concatenation):");
31+
Serial.println();
3032
}
3133

3234
void loop() {

build/shared/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ String stringOne, stringTwo;
1616
void setup() {
1717
// Open serial communications and wait for port to open:
1818
Serial.begin(9600);
19-
// this check is only needed on the Leonardo:
20-
while (!Serial) ;
21-
;
19+
while (!Serial) {
20+
; // wait for serial port to connect. Needed for Leonardo only
21+
}
2222

2323
stringOne = String("Sensor ");
2424
stringTwo = String("value");
25+
// send an intro:
2526
Serial.println("\n\nAppending to a string:");
27+
Serial.println();
2628
}
2729

2830
void loop() {

build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
void setup() {
1616
// Open serial communications and wait for port to open:
1717
Serial.begin(9600);
18-
// this check is only needed on the Leonardo:
19-
while (!Serial) ;
20-
;
18+
while (!Serial) {
19+
; // wait for serial port to connect. Needed for Leonardo only
20+
}
2121

22+
// send an intro:
2223
Serial.println("\n\nString case changes:");
24+
Serial.println();
2325
}
2426

2527
void loop() {

build/shared/examples/08.Strings/StringCharacters/StringCharacters.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
void setup() {
1616
// Open serial communications and wait for port to open:
1717
Serial.begin(9600);
18-
// this check is only needed on the Leonardo:
19-
while (!Serial) ;
20-
;
18+
while (!Serial) {
19+
; // wait for serial port to connect. Needed for Leonardo only
20+
}
2121

2222
Serial.println("\n\nString charAt() and setCharAt():");
2323
}

0 commit comments

Comments
 (0)