From 6f93d3fc174689e0a7fa3c287eabaf5ccf776372 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 9 Apr 2012 09:51:35 -0400 Subject: [PATCH] Updated all comments for while (!Serial) additions to serial-based examples --- .../examples/04.Communication/ASCIITable/ASCIITable.ino | 7 ++++--- .../SerialCallResponseASCII/SerialCallResponseASCII.ino | 9 +++++---- libraries/Ethernet/examples/ChatServer/ChatServer.ino | 9 +++++---- .../examples/DhcpAddressPrinter/DhcpAddressPrinter.ino | 7 ++++--- .../Ethernet/examples/DhcpChatServer/DhcpChatServer.ino | 8 +++++--- .../Ethernet/examples/DnsWebClient/DnsWebClient.ino | 9 +++++---- .../Ethernet/examples/PachubeClient/PachubeClient.ino | 9 +++++---- .../examples/PachubeClientString/PachubeClientString.ino | 9 +++++---- .../Ethernet/examples/TelnetClient/TelnetClient.ino | 9 +++++---- .../Ethernet/examples/TwitterClient/TwitterClient.ino | 9 +++++---- .../Ethernet/examples/UdpNtpClient/UdpNtpClient.ino | 9 +++++---- libraries/Ethernet/examples/WebClient/WebClient.ino | 8 ++++---- libraries/Ethernet/examples/WebServer/WebServer.ino | 9 +++++---- libraries/SD/examples/CardInfo/CardInfo.ino | 9 +++++---- libraries/SD/examples/Datalogger/Datalogger.ino | 9 +++++---- libraries/SD/examples/DumpFile/DumpFile.ino | 9 +++++---- libraries/SD/examples/Files/Files.ino | 9 +++++---- libraries/SD/examples/ReadWrite/ReadWrite.ino | 9 +++++---- libraries/SD/examples/listfiles/listfiles.ino | 9 +++++---- .../SoftwareSerialExample/SoftwareSerialExample.ino | 9 +++++---- .../examples/TwoPortReceive/TwoPortReceive.ino | 9 +++++---- 21 files changed, 102 insertions(+), 81 deletions(-) diff --git a/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino b/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino index e993c2137..9d8524784 100644 --- a/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino +++ b/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino @@ -11,7 +11,7 @@ created 2006 by Nicholas Zambetti - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. @@ -22,8 +22,9 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } // prints title with ending line break Serial.println("ASCII Table ~ Character Map"); diff --git a/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino b/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino index 2c4f3cd88..772ae3f4f 100644 --- a/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino +++ b/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino @@ -19,7 +19,7 @@ Created 26 Sept. 2005 by Tom Igoe - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe and Scott Fitzgerald This example code is in the public domain. @@ -37,9 +37,10 @@ void setup() { // start serial port at 9600 bps and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + pinMode(2, INPUT); // digital sensor is on digital pin 2 establishContact(); // send a byte to establish contact until receiver responds diff --git a/libraries/Ethernet/examples/ChatServer/ChatServer.ino b/libraries/Ethernet/examples/ChatServer/ChatServer.ino index a61d17e54..d50e5a657 100644 --- a/libraries/Ethernet/examples/ChatServer/ChatServer.ino +++ b/libraries/Ethernet/examples/ChatServer/ChatServer.ino @@ -12,7 +12,7 @@ created 18 Dec 2009 by David A. Mellis - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe */ @@ -41,9 +41,10 @@ void setup() { server.begin(); // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + Serial.print("Chat server address:"); Serial.println(Ethernet.localIP()); diff --git a/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino b/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino index 6ae5253fe..5eaaf24d1 100644 --- a/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino +++ b/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino @@ -9,7 +9,7 @@ * Ethernet shield attached to pins 10, 11, 12, 13 created 12 April 2011 - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe */ @@ -31,8 +31,9 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { diff --git a/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino b/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino index 222251a94..09cbd4354 100644 --- a/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino +++ b/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino @@ -12,7 +12,7 @@ * Ethernet shield attached to pins 10, 11, 12, 13 created 21 May 2011 - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe Based on ChatServer example by David A. Mellis @@ -38,8 +38,10 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + // start the Ethernet connection: Serial.println("Trying to get an IP address using DHCP"); diff --git a/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.ino b/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.ino index f15b835f9..c14abf403 100644 --- a/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.ino +++ b/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.ino @@ -9,7 +9,7 @@ created 18 Dec 2009 by David A. Mellis - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe, based on work by Adrian McEwen */ @@ -30,9 +30,10 @@ EthernetClient client; void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { diff --git a/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino b/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino index 3b5ce9c13..dfd2d4010 100644 --- a/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino +++ b/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino @@ -16,7 +16,7 @@ * Ethernet shield attached to pins 10, 11, 12, 13 created 15 March 2010 - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe with input from Usman Haque and Joe Saavedra http://arduino.cc/en/Tutorial/PachubeClient @@ -55,9 +55,10 @@ const unsigned long postingInterval = 10*1000; //delay between updates to Pachub void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { diff --git a/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino b/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino index dda28db82..5ffd8f08c 100644 --- a/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino +++ b/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino @@ -18,7 +18,7 @@ * Ethernet shield attached to pins 10, 11, 12, 13 created 15 March 2010 - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe with input from Usman Haque and Joe Saavedra http://arduino.cc/en/Tutorial/PachubeClientString @@ -57,9 +57,10 @@ const unsigned long postingInterval = 10*1000; //delay between updates to Pachu void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + // give the ethernet module time to boot up: delay(1000); diff --git a/libraries/Ethernet/examples/TelnetClient/TelnetClient.ino b/libraries/Ethernet/examples/TelnetClient/TelnetClient.ino index b9a22947f..345712564 100644 --- a/libraries/Ethernet/examples/TelnetClient/TelnetClient.ino +++ b/libraries/Ethernet/examples/TelnetClient/TelnetClient.ino @@ -13,7 +13,7 @@ * Ethernet shield attached to pins 10, 11, 12, 13 created 14 Sep 2010 - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe */ @@ -41,9 +41,10 @@ void setup() { Ethernet.begin(mac, ip); // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + // give the Ethernet shield a second to initialize: delay(1000); diff --git a/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino b/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino index b704f4f62..3587d72d3 100644 --- a/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino +++ b/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino @@ -17,7 +17,7 @@ * Ethernet shield attached to pins 10, 11, 12, 13 created 21 May 2011 - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe This code is in the public domain. @@ -54,9 +54,10 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + // attempt a DHCP connection: Serial.println("Attempting to get an IP address using DHCP:"); diff --git a/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino b/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino index 7367af8b0..93ffe3991 100644 --- a/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino +++ b/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino @@ -9,7 +9,7 @@ created 4 Sep 2010 by Michael Margolis - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe This code is in the public domain. @@ -40,9 +40,10 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + // start Ethernet and UDP if (Ethernet.begin(mac) == 0) { diff --git a/libraries/Ethernet/examples/WebClient/WebClient.ino b/libraries/Ethernet/examples/WebClient/WebClient.ino index 054a13e27..5d5d7f20b 100644 --- a/libraries/Ethernet/examples/WebClient/WebClient.ino +++ b/libraries/Ethernet/examples/WebClient/WebClient.ino @@ -8,7 +8,7 @@ * Ethernet shield attached to pins 10, 11, 12, 13 created 18 Dec 2009 - modified 2 Apr 2012 + modified 9 Apr 2012 by David A. Mellis */ @@ -29,9 +29,9 @@ EthernetClient client; void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { diff --git a/libraries/Ethernet/examples/WebServer/WebServer.ino b/libraries/Ethernet/examples/WebServer/WebServer.ino index 57368489a..ce8dbb1b0 100644 --- a/libraries/Ethernet/examples/WebServer/WebServer.ino +++ b/libraries/Ethernet/examples/WebServer/WebServer.ino @@ -10,7 +10,7 @@ created 18 Dec 2009 by David A. Mellis - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe */ @@ -32,9 +32,10 @@ EthernetServer server(80); void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + // start the Ethernet connection and the server: Ethernet.begin(mac, ip); diff --git a/libraries/SD/examples/CardInfo/CardInfo.ino b/libraries/SD/examples/CardInfo/CardInfo.ino index 0fa864740..0c2dfc5e2 100644 --- a/libraries/SD/examples/CardInfo/CardInfo.ino +++ b/libraries/SD/examples/CardInfo/CardInfo.ino @@ -16,7 +16,7 @@ created 28 Mar 2011 by Limor Fried - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe */ // include the SD library: @@ -37,9 +37,10 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + Serial.print("\nInitializing SD card..."); // On the Ethernet Shield, CS is pin 4. It's set as an output by default. diff --git a/libraries/SD/examples/Datalogger/Datalogger.ino b/libraries/SD/examples/Datalogger/Datalogger.ino index 9e1d8e7ce..a7f85eeaf 100644 --- a/libraries/SD/examples/Datalogger/Datalogger.ino +++ b/libraries/SD/examples/Datalogger/Datalogger.ino @@ -13,7 +13,7 @@ ** CS - pin 4 created 24 Nov 2010 - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. @@ -32,9 +32,10 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + Serial.print("Initializing SD card..."); // make sure that the default chip select pin is set to diff --git a/libraries/SD/examples/DumpFile/DumpFile.ino b/libraries/SD/examples/DumpFile/DumpFile.ino index 9de34c4c8..d83089af6 100644 --- a/libraries/SD/examples/DumpFile/DumpFile.ino +++ b/libraries/SD/examples/DumpFile/DumpFile.ino @@ -13,7 +13,7 @@ created 22 December 2010 by Limor Fried - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. @@ -32,9 +32,10 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + Serial.print("Initializing SD card..."); // make sure that the default chip select pin is set to diff --git a/libraries/SD/examples/Files/Files.ino b/libraries/SD/examples/Files/Files.ino index 983c67fac..a15b8626d 100644 --- a/libraries/SD/examples/Files/Files.ino +++ b/libraries/SD/examples/Files/Files.ino @@ -11,7 +11,7 @@ created Nov 2010 by David A. Mellis - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. @@ -25,9 +25,10 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + Serial.print("Initializing SD card..."); // On the Ethernet Shield, CS is pin 4. It's set as an output by default. diff --git a/libraries/SD/examples/ReadWrite/ReadWrite.ino b/libraries/SD/examples/ReadWrite/ReadWrite.ino index 5d1037404..5805fc8d6 100644 --- a/libraries/SD/examples/ReadWrite/ReadWrite.ino +++ b/libraries/SD/examples/ReadWrite/ReadWrite.ino @@ -11,7 +11,7 @@ created Nov 2010 by David A. Mellis - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. @@ -26,9 +26,10 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + Serial.print("Initializing SD card..."); // On the Ethernet Shield, CS is pin 4. It's set as an output by default. diff --git a/libraries/SD/examples/listfiles/listfiles.ino b/libraries/SD/examples/listfiles/listfiles.ino index 1faef1184..876c3f865 100644 --- a/libraries/SD/examples/listfiles/listfiles.ino +++ b/libraries/SD/examples/listfiles/listfiles.ino @@ -11,7 +11,7 @@ created Nov 2010 by David A. Mellis - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. @@ -25,9 +25,10 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + Serial.print("Initializing SD card..."); // On the Ethernet Shield, CS is pin 4. It's set as an output by default. diff --git a/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino index a19307b14..560965d23 100644 --- a/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino +++ b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino @@ -9,7 +9,7 @@ * TX is digital pin 3 (connect to RX of other device) created back in the mists of time - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe based on Mikal Hart's example @@ -24,9 +24,10 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin57600; - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + Serial.println("Goodnight moon!"); diff --git a/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino index bc0ae725c..d9f8f453f 100644 --- a/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino +++ b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino @@ -17,7 +17,7 @@ * Second serial device's TX attached to digital pin 4, RX to pin 5 created 18 Apr. 2011 - modified 2 Apr 2012 + modified 9 Apr 2012 by Tom Igoe based on Mikal Hart's twoPortRXExample @@ -36,9 +36,10 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); - // this check is only needed on the Leonardo: - while (!Serial) ; - ; + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + // Start each software serial port portOne.begin(9600);