Skip to content

Commit 202bb10

Browse files
author
Tom Igoe
committed
Updated all serial in setup examples with a note about the serial check
1 parent a631e4f commit 202bb10

File tree

32 files changed

+91
-28
lines changed

32 files changed

+91
-28
lines changed

build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
void setup() {
2323
//Initialize serial and wait for port to open:
2424
Serial.begin(9600);
25+
// this check is only needed on the Leonardo:
2526
while (!Serial) ;
2627

2728
// prints title with ending line break

build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino

+2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ void setup()
3737
{
3838
// start serial port at 9600 bps and wait for port to open:
3939
Serial.begin(9600);
40+
// this check is only needed on the Leonardo:
4041
while (!Serial) ;
42+
;
4143

4244
pinMode(2, INPUT); // digital sensor is on digital pin 2
4345
establishContact(); // send a byte to establish contact until receiver responds

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
void setup() {
1515
// Open serial communications and wait for port to open:
1616
Serial.begin(9600);
17-
while(!Serial) ;
17+
// this check is only needed on the Leonardo:
18+
while (!Serial) ;
19+
;
1820

1921
// send an intro:
2022
Serial.println("send any byte and I'll tell you everything I can about it");

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

+2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ 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:
2223
while (!Serial) ;
24+
;
2325

2426
stringOne = String("stringThree = ");
2527
stringTwo = String("this string");

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ String stringOne, stringTwo;
1616
void setup() {
1717
// Open serial communications and wait for port to open:
1818
Serial.begin(9600);
19-
while(!Serial) ;
19+
// this check is only needed on the Leonardo:
20+
while (!Serial) ;
21+
;
2022

2123
stringOne = String("Sensor ");
2224
stringTwo = String("value");

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

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

2022
Serial.println("\n\nString case changes:");
2123
}

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

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

2022
Serial.println("\n\nString charAt() and setCharAt():");
2123
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ String stringOne, stringTwo;
1717
void setup() {
1818
// Open serial communications and wait for port to open:
1919
Serial.begin(9600);
20-
while(!Serial) ;
20+
// this check is only needed on the Leonardo:
21+
while (!Serial) ;
22+
;
2123

2224
stringOne = String("this");
2325
stringTwo = String("that");

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

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

2022
Serial.println("\n\nString indexOf() and lastIndexOf() functions:");
2123

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

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

2022
Serial.println("\n\nString length() and trim():");
2123
}

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

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

2022
Serial.println("\n\nString replace:");
2123
}

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

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

2022
Serial.println("\n\nString startsWith() and endsWith():");
2123

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

+2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
void setup() {
1616
Serial.begin(9600);
1717
// Wait for port to be opened:
18+
// this check is only needed on the Leonardo:
1819
while (!Serial) ;
20+
;
1921

2022
Serial.println("\n\nString substring():");
2123
}

libraries/Ethernet/examples/ChatServer/ChatServer.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ void setup() {
4141
server.begin();
4242
// Open serial communications and wait for port to open:
4343
Serial.begin(9600);
44-
while(!Serial) ;
44+
// this check is only needed on the Leonardo:
45+
while (!Serial) ;
46+
;
4547

4648
Serial.print("Chat server address:");
4749
Serial.println(Ethernet.localIP());

libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ EthernetClient client;
3030
void setup() {
3131
// Open serial communications and wait for port to open:
3232
Serial.begin(9600);
33-
while(!Serial) ;
33+
// this check is only needed on the Leonardo:
34+
while (!Serial) ;
35+
;
3436

3537
// start the Ethernet connection:
3638
if (Ethernet.begin(mac) == 0) {

libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ boolean gotAMessage = false; // whether or not you got a message from the client
3737
void setup() {
3838
// Open serial communications and wait for port to open:
3939
Serial.begin(9600);
40-
while(!Serial) ;
40+
// this check is only needed on the Leonardo:
41+
while (!Serial) ;
42+
;
4143

4244
// start the Ethernet connection:
4345
Serial.println("Trying to get an IP address using DHCP");

libraries/Ethernet/examples/DnsWebClient/DnsWebClient.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ EthernetClient client;
3030
void setup() {
3131
// Open serial communications and wait for port to open:
3232
Serial.begin(9600);
33-
while(!Serial) ;
33+
// this check is only needed on the Leonardo:
34+
while (!Serial) ;
35+
;
3436

3537
// start the Ethernet connection:
3638
if (Ethernet.begin(mac) == 0) {

libraries/Ethernet/examples/PachubeClient/PachubeClient.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ const unsigned long postingInterval = 10*1000; //delay between updates to Pachub
5555
void setup() {
5656
// Open serial communications and wait for port to open:
5757
Serial.begin(9600);
58-
while(!Serial) ;
58+
// this check is only needed on the Leonardo:
59+
while (!Serial) ;
60+
;
5961

6062
// start the Ethernet connection:
6163
if (Ethernet.begin(mac) == 0) {

libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ const unsigned long postingInterval = 10*1000; //delay between updates to Pachu
5757
void setup() {
5858
// Open serial communications and wait for port to open:
5959
Serial.begin(9600);
60-
while(!Serial) ;
60+
// this check is only needed on the Leonardo:
61+
while (!Serial) ;
62+
;
6163

6264
// give the ethernet module time to boot up:
6365
delay(1000);

libraries/Ethernet/examples/TelnetClient/TelnetClient.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ void setup() {
4141
Ethernet.begin(mac, ip);
4242
// Open serial communications and wait for port to open:
4343
Serial.begin(9600);
44-
while(!Serial) ;
44+
// this check is only needed on the Leonardo:
45+
while (!Serial) ;
46+
;
4547

4648
// give the Ethernet shield a second to initialize:
4749
delay(1000);

libraries/Ethernet/examples/TwitterClient/TwitterClient.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ void setup() {
5454

5555
// Open serial communications and wait for port to open:
5656
Serial.begin(9600);
57-
while(!Serial) ;
57+
// this check is only needed on the Leonardo:
58+
while (!Serial) ;
59+
;
5860

5961
// attempt a DHCP connection:
6062
Serial.println("Attempting to get an IP address using DHCP:");

libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ void setup()
4040
{
4141
// Open serial communications and wait for port to open:
4242
Serial.begin(9600);
43-
while(!Serial) ;
43+
// this check is only needed on the Leonardo:
44+
while (!Serial) ;
45+
;
4446

4547
// start Ethernet and UDP
4648
if (Ethernet.begin(mac) == 0) {

libraries/Ethernet/examples/WebClient/WebClient.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ EthernetClient client;
2929
void setup() {
3030
// Open serial communications and wait for port to open:
3131
Serial.begin(9600);
32-
while(!Serial) ;
32+
// this check is only needed on the Leonardo:
33+
while (!Serial) ;
34+
;
3335

3436
// start the Ethernet connection:
3537
if (Ethernet.begin(mac) == 0) {

libraries/Ethernet/examples/WebServer/WebServer.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ EthernetServer server(80);
3232
void setup() {
3333
// Open serial communications and wait for port to open:
3434
Serial.begin(9600);
35-
while(!Serial) ;
35+
// this check is only needed on the Leonardo:
36+
while (!Serial) ;
37+
;
3638

3739
// start the Ethernet connection and the server:
3840
Ethernet.begin(mac, ip);

libraries/SD/examples/CardInfo/CardInfo.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ void setup()
3737
{
3838
// Open serial communications and wait for port to open:
3939
Serial.begin(9600);
40-
while(!Serial) ;
40+
// this check is only needed on the Leonardo:
41+
while (!Serial) ;
42+
;
4143

4244
Serial.print("\nInitializing SD card...");
4345
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.

libraries/SD/examples/Datalogger/Datalogger.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ void setup()
3232
{
3333
// Open serial communications and wait for port to open:
3434
Serial.begin(9600);
35-
while(!Serial) ;
35+
// this check is only needed on the Leonardo:
36+
while (!Serial) ;
37+
;
3638

3739
Serial.print("Initializing SD card...");
3840
// make sure that the default chip select pin is set to

libraries/SD/examples/DumpFile/DumpFile.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ void setup()
3232
{
3333
// Open serial communications and wait for port to open:
3434
Serial.begin(9600);
35-
while(!Serial) ;
35+
// this check is only needed on the Leonardo:
36+
while (!Serial) ;
37+
;
3638

3739
Serial.print("Initializing SD card...");
3840
// make sure that the default chip select pin is set to

libraries/SD/examples/Files/Files.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ void setup()
2525
{
2626
// Open serial communications and wait for port to open:
2727
Serial.begin(9600);
28-
while(!Serial) ;
28+
// this check is only needed on the Leonardo:
29+
while (!Serial) ;
30+
;
2931

3032
Serial.print("Initializing SD card...");
3133
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.

libraries/SD/examples/ReadWrite/ReadWrite.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ void setup()
2626
{
2727
// Open serial communications and wait for port to open:
2828
Serial.begin(9600);
29-
while(!Serial) ;
29+
// this check is only needed on the Leonardo:
30+
while (!Serial) ;
31+
;
3032

3133
Serial.print("Initializing SD card...");
3234
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.

libraries/SD/examples/listfiles/listfiles.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ void setup()
2525
{
2626
// Open serial communications and wait for port to open:
2727
Serial.begin(9600);
28-
while(!Serial) ;
28+
// this check is only needed on the Leonardo:
29+
while (!Serial) ;
30+
;
2931

3032
Serial.print("Initializing SD card...");
3133
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.

libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ void setup()
2424
{
2525
// Open serial communications and wait for port to open:
2626
Serial.begin57600;
27-
while(!Serial) ;
27+
// this check is only needed on the Leonardo:
28+
while (!Serial) ;
29+
;
2830

2931
Serial.println("Goodnight moon!");
3032

libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ void setup()
3636
{
3737
// Open serial communications and wait for port to open:
3838
Serial.begin(9600);
39-
while(!Serial) ;
39+
// this check is only needed on the Leonardo:
40+
while (!Serial) ;
41+
;
4042

4143
// Start each software serial port
4244
portOne.begin(9600);

0 commit comments

Comments
 (0)