1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

Added Serial port check to all examples using Serial statements in the setup

This commit is contained in:
Tom Igoe
2012-04-02 09:07:58 -04:00
parent e9a00eb38f
commit a631e4f834
32 changed files with 132 additions and 40 deletions

View File

@ -11,7 +11,7 @@
created 2006 created 2006
by Nicholas Zambetti by Nicholas Zambetti
modified 30 Aug 2011 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
@ -19,10 +19,11 @@
<http://www.zambetti.com> <http://www.zambetti.com>
*/ */
void setup() void setup() {
{ //Initialize serial and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while (!Serial) ;
// prints title with ending line break // prints title with ending line break
Serial.println("ASCII Table ~ Character Map"); Serial.println("ASCII Table ~ Character Map");
} }
@ -33,8 +34,7 @@ int thisByte = 33;
// for example. '!' is the same as 33, so you could also use this: // for example. '!' is the same as 33, so you could also use this:
//int thisByte = '!'; //int thisByte = '!';
void loop() void loop() {
{
// prints value unaltered, i.e. the raw binary version of the // prints value unaltered, i.e. the raw binary version of the
// byte. The serial monitor interprets all bytes as // byte. The serial monitor interprets all bytes as
// ASCII, so 33, the first number, will show up as '!' // ASCII, so 33, the first number, will show up as '!'

View File

@ -19,7 +19,7 @@
Created 26 Sept. 2005 Created 26 Sept. 2005
by Tom Igoe by Tom Igoe
modified 26 Oct 2011 modified 2 Apr 2012
by Tom Igoe and Scott Fitzgerald by Tom Igoe and Scott Fitzgerald
This example code is in the public domain. This example code is in the public domain.
@ -35,8 +35,10 @@ int inByte = 0; // incoming serial byte
void setup() void setup()
{ {
// start serial port at 9600 bps: // start serial port at 9600 bps and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while (!Serial) ;
pinMode(2, INPUT); // digital sensor is on digital pin 2 pinMode(2, INPUT); // digital sensor is on digital pin 2
establishContact(); // send a byte to establish contact until receiver responds establishContact(); // send a byte to establish contact until receiver responds
} }

View File

@ -5,14 +5,16 @@
Send any byte and the sketch will tell you about it. Send any byte and the sketch will tell you about it.
created 29 Nov 2010 created 29 Nov 2010
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
*/ */
void setup() { void setup() {
// Open serial communications: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// send an intro: // send an intro:
Serial.println("send any byte and I'll tell you everything I can about it"); Serial.println("send any byte and I'll tell you everything I can about it");

View File

@ -5,7 +5,7 @@
You can also add several different data types to string, as shown here: You can also add several different data types to string, as shown here:
created 27 July 2010 created 27 July 2010
modified 30 Aug 2011 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
http://arduino.cc/en/Tutorial/StringAdditionOperator http://arduino.cc/en/Tutorial/StringAdditionOperator
@ -17,7 +17,10 @@
String stringOne, stringTwo, stringThree; String stringOne, stringTwo, stringThree;
void setup() { void setup() {
// initialize serial and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while (!Serial) ;
stringOne = String("stringThree = "); stringOne = String("stringThree = ");
stringTwo = String("this string"); stringTwo = String("this string");
stringThree = String (); stringThree = String ();

View File

@ -4,7 +4,7 @@
Examples of how to append different data types to strings Examples of how to append different data types to strings
created 27 July 2010 created 27 July 2010
modified 30 Aug 2011 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
http://arduino.cc/en/Tutorial/StringAppendOperator http://arduino.cc/en/Tutorial/StringAppendOperator
@ -14,7 +14,10 @@
String stringOne, stringTwo; String stringOne, stringTwo;
void setup() { void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
stringOne = String("Sensor "); stringOne = String("Sensor ");
stringTwo = String("value"); stringTwo = String("value");
Serial.println("\n\nAppending to a string:"); Serial.println("\n\nAppending to a string:");

View File

@ -4,6 +4,7 @@
Examples of how to change the case of a string Examples of how to change the case of a string
created 27 July 2010 created 27 July 2010
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
http://arduino.cc/en/Tutorial/StringCaseChanges http://arduino.cc/en/Tutorial/StringCaseChanges
@ -12,7 +13,10 @@
*/ */
void setup() { void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.println("\n\nString case changes:"); Serial.println("\n\nString case changes:");
} }

View File

@ -4,6 +4,7 @@
Examples of how to get and set characters of a String Examples of how to get and set characters of a String
created 27 July 2010 created 27 July 2010
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
http://arduino.cc/en/Tutorial/StringCharacters http://arduino.cc/en/Tutorial/StringCharacters
@ -12,7 +13,10 @@
*/ */
void setup() { void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.println("\n\nString charAt() and setCharAt():"); Serial.println("\n\nString charAt() and setCharAt():");
} }

View File

@ -4,7 +4,7 @@
Examples of how to compare strings using the comparison operators Examples of how to compare strings using the comparison operators
created 27 July 2010 created 27 July 2010
modified 30 Aug 2011 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
http://arduino.cc/en/Tutorial/StringComparisonOperators http://arduino.cc/en/Tutorial/StringComparisonOperators
@ -15,7 +15,10 @@
String stringOne, stringTwo; String stringOne, stringTwo;
void setup() { void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
stringOne = String("this"); stringOne = String("this");
stringTwo = String("that"); stringTwo = String("that");
Serial.println("\n\nComparing Strings:"); Serial.println("\n\nComparing Strings:");

View File

@ -4,6 +4,7 @@
Examples of how to evaluate, look for, and replace characters in a String Examples of how to evaluate, look for, and replace characters in a String
created 27 July 2010 created 27 July 2010
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
http://arduino.cc/en/Tutorial/StringIndexOf http://arduino.cc/en/Tutorial/StringIndexOf
@ -12,7 +13,10 @@
*/ */
void setup() { void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.println("\n\nString indexOf() and lastIndexOf() functions:"); Serial.println("\n\nString indexOf() and lastIndexOf() functions:");
} }

View File

@ -4,6 +4,7 @@
Examples of how to use length() and trim() in a String Examples of how to use length() and trim() in a String
created 27 July 2010 created 27 July 2010
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
http://arduino.cc/en/Tutorial/StringLengthTrim http://arduino.cc/en/Tutorial/StringLengthTrim
@ -12,7 +13,10 @@
*/ */
void setup() { void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.println("\n\nString length() and trim():"); Serial.println("\n\nString length() and trim():");
} }

View File

@ -4,6 +4,7 @@
Examples of how to replace characters or substrings of a string Examples of how to replace characters or substrings of a string
created 27 July 2010 created 27 July 2010
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
http://arduino.cc/en/Tutorial/StringReplace http://arduino.cc/en/Tutorial/StringReplace
@ -12,7 +13,10 @@
*/ */
void setup() { void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.println("\n\nString replace:"); Serial.println("\n\nString replace:");
} }

View File

@ -4,7 +4,7 @@
Examples of how to use startsWith() and endsWith() in a String Examples of how to use startsWith() and endsWith() in a String
created 27 July 2010 created 27 July 2010
modified 30 Aug 2011 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
http://arduino.cc/en/Tutorial/StringStartsWithEndsWith http://arduino.cc/en/Tutorial/StringStartsWithEndsWith
@ -13,7 +13,10 @@
*/ */
void setup() { void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.println("\n\nString startsWith() and endsWith():"); Serial.println("\n\nString startsWith() and endsWith():");
} }

View File

@ -3,8 +3,9 @@
Examples of how to use substring in a String Examples of how to use substring in a String
created 27 July 2010, modified 1 April 2012 created 27 July 2010,
by Tom Igoe modified 2 Apr 2012
by Zach Eveland
http://arduino.cc/en/Tutorial/StringSubstring http://arduino.cc/en/Tutorial/StringSubstring
@ -14,8 +15,8 @@
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// Wait for port to be opened: // Wait for port to be opened:
while (!Serial) while (!Serial) ;
;
Serial.println("\n\nString substring():"); Serial.println("\n\nString substring():");
} }
@ -35,4 +36,4 @@ void loop() {
// do nothing while true: // do nothing while true:
while(true); while(true);
} }

View File

@ -12,7 +12,7 @@
created 18 Dec 2009 created 18 Dec 2009
by David A. Mellis by David A. Mellis
modified 12 March 2012 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
*/ */
@ -39,8 +39,10 @@ void setup() {
Ethernet.begin(mac, ip, gateway, subnet); Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients // start listening for clients
server.begin(); server.begin();
// open the serial port // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.print("Chat server address:"); Serial.print("Chat server address:");
Serial.println(Ethernet.localIP()); Serial.println(Ethernet.localIP());
} }

View File

@ -9,6 +9,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13 * Ethernet shield attached to pins 10, 11, 12, 13
created 12 April 2011 created 12 April 2011
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
*/ */
@ -27,8 +28,10 @@ byte mac[] = {
EthernetClient client; EthernetClient client;
void setup() { void setup() {
// start the serial library: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// start the Ethernet connection: // start the Ethernet connection:
if (Ethernet.begin(mac) == 0) { if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP"); Serial.println("Failed to configure Ethernet using DHCP");

View File

@ -12,6 +12,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13 * Ethernet shield attached to pins 10, 11, 12, 13
created 21 May 2011 created 21 May 2011
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
Based on ChatServer example by David A. Mellis Based on ChatServer example by David A. Mellis
@ -34,8 +35,10 @@ EthernetServer server(23);
boolean gotAMessage = false; // whether or not you got a message from the client yet boolean gotAMessage = false; // whether or not you got a message from the client yet
void setup() { void setup() {
// open the serial port // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// start the Ethernet connection: // start the Ethernet connection:
Serial.println("Trying to get an IP address using DHCP"); Serial.println("Trying to get an IP address using DHCP");
if (Ethernet.begin(mac) == 0) { if (Ethernet.begin(mac) == 0) {

View File

@ -9,7 +9,7 @@
created 18 Dec 2009 created 18 Dec 2009
by David A. Mellis by David A. Mellis
modified 12 April 2011 modified 2 Apr 2012
by Tom Igoe, based on work by Adrian McEwen by Tom Igoe, based on work by Adrian McEwen
*/ */
@ -28,8 +28,10 @@ char serverName[] = "www.google.com";
EthernetClient client; EthernetClient client;
void setup() { void setup() {
// start the serial library: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// start the Ethernet connection: // start the Ethernet connection:
if (Ethernet.begin(mac) == 0) { if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP"); Serial.println("Failed to configure Ethernet using DHCP");

View File

@ -16,7 +16,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13 * Ethernet shield attached to pins 10, 11, 12, 13
created 15 March 2010 created 15 March 2010
updated 16 Mar 2012 modified 2 Apr 2012
by Tom Igoe with input from Usman Haque and Joe Saavedra by Tom Igoe with input from Usman Haque and Joe Saavedra
http://arduino.cc/en/Tutorial/PachubeClient http://arduino.cc/en/Tutorial/PachubeClient
@ -53,8 +53,10 @@ boolean lastConnected = false; // state of the connection last t
const unsigned long postingInterval = 10*1000; //delay between updates to Pachube.com const unsigned long postingInterval = 10*1000; //delay between updates to Pachube.com
void setup() { void setup() {
// start serial port: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// start the Ethernet connection: // start the Ethernet connection:
if (Ethernet.begin(mac) == 0) { if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP"); Serial.println("Failed to configure Ethernet using DHCP");

View File

@ -18,7 +18,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13 * Ethernet shield attached to pins 10, 11, 12, 13
created 15 March 2010 created 15 March 2010
updated 16 Mar 2012 modified 2 Apr 2012
by Tom Igoe with input from Usman Haque and Joe Saavedra by Tom Igoe with input from Usman Haque and Joe Saavedra
http://arduino.cc/en/Tutorial/PachubeClientString http://arduino.cc/en/Tutorial/PachubeClientString
@ -55,8 +55,10 @@ boolean lastConnected = false; // state of the connection last t
const unsigned long postingInterval = 10*1000; //delay between updates to Pachube.com const unsigned long postingInterval = 10*1000; //delay between updates to Pachube.com
void setup() { void setup() {
// start serial port: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// give the ethernet module time to boot up: // give the ethernet module time to boot up:
delay(1000); delay(1000);
// start the Ethernet connection: // start the Ethernet connection:

View File

@ -13,6 +13,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13 * Ethernet shield attached to pins 10, 11, 12, 13
created 14 Sep 2010 created 14 Sep 2010
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
*/ */
@ -38,8 +39,10 @@ EthernetClient client;
void setup() { void setup() {
// start the Ethernet connection: // start the Ethernet connection:
Ethernet.begin(mac, ip); Ethernet.begin(mac, ip);
// start the serial library: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// give the Ethernet shield a second to initialize: // give the Ethernet shield a second to initialize:
delay(1000); delay(1000);
Serial.println("connecting..."); Serial.println("connecting...");

View File

@ -17,6 +17,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13 * Ethernet shield attached to pins 10, 11, 12, 13
created 21 May 2011 created 21 May 2011
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
This code is in the public domain. This code is in the public domain.
@ -51,8 +52,10 @@ void setup() {
currentLine.reserve(256); currentLine.reserve(256);
tweet.reserve(150); tweet.reserve(150);
// initialize serial: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// attempt a DHCP connection: // attempt a DHCP connection:
Serial.println("Attempting to get an IP address using DHCP:"); Serial.println("Attempting to get an IP address using DHCP:");
if (!Ethernet.begin(mac)) { if (!Ethernet.begin(mac)) {

View File

@ -9,7 +9,7 @@
created 4 Sep 2010 created 4 Sep 2010
by Michael Margolis by Michael Margolis
modified 17 Sep 2010 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
This code is in the public domain. This code is in the public domain.
@ -38,7 +38,9 @@ EthernetUDP Udp;
void setup() void setup()
{ {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// start Ethernet and UDP // start Ethernet and UDP
if (Ethernet.begin(mac) == 0) { if (Ethernet.begin(mac) == 0) {

View File

@ -8,6 +8,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13 * Ethernet shield attached to pins 10, 11, 12, 13
created 18 Dec 2009 created 18 Dec 2009
modified 2 Apr 2012
by David A. Mellis by David A. Mellis
*/ */
@ -26,8 +27,10 @@ IPAddress server(173,194,33,104); // Google
EthernetClient client; EthernetClient client;
void setup() { void setup() {
// start the serial library: // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// start the Ethernet connection: // start the Ethernet connection:
if (Ethernet.begin(mac) == 0) { if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP"); Serial.println("Failed to configure Ethernet using DHCP");

View File

@ -10,7 +10,7 @@
created 18 Dec 2009 created 18 Dec 2009
by David A. Mellis by David A. Mellis
modified 20 Mar 2012 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
*/ */
@ -30,7 +30,10 @@ IPAddress ip(192,168,1, 177);
EthernetServer server(80); EthernetServer server(80);
void setup() { void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// start the Ethernet connection and the server: // start the Ethernet connection and the server:
Ethernet.begin(mac, ip); Ethernet.begin(mac, ip);
server.begin(); server.begin();

View File

@ -16,7 +16,7 @@
created 28 Mar 2011 created 28 Mar 2011
by Limor Fried by Limor Fried
modified 16 Mar 2011 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
*/ */
// include the SD library: // include the SD library:
@ -35,7 +35,10 @@ const int chipSelect = 4;
void setup() void setup()
{ {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.print("\nInitializing SD card..."); Serial.print("\nInitializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default. // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin // Note that even if it's not used as the CS pin, the hardware SS pin

View File

@ -13,7 +13,7 @@
** CS - pin 4 ** CS - pin 4
created 24 Nov 2010 created 24 Nov 2010
updated 2 Dec 2010 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
@ -30,7 +30,10 @@ const int chipSelect = 4;
void setup() void setup()
{ {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.print("Initializing SD card..."); Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to // make sure that the default chip select pin is set to
// output, even if you don't use it: // output, even if you don't use it:

View File

@ -12,6 +12,9 @@
** CS - pin 4 ** CS - pin 4
created 22 December 2010 created 22 December 2010
by Limor Fried
modified 2 Apr 2012
by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
@ -27,7 +30,10 @@ const int chipSelect = 4;
void setup() void setup()
{ {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.print("Initializing SD card..."); Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to // make sure that the default chip select pin is set to
// output, even if you don't use it: // output, even if you don't use it:

View File

@ -11,7 +11,7 @@
created Nov 2010 created Nov 2010
by David A. Mellis by David A. Mellis
updated 2 Dec 2010 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
@ -23,7 +23,10 @@ File myFile;
void setup() void setup()
{ {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.print("Initializing SD card..."); Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default. // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin // Note that even if it's not used as the CS pin, the hardware SS pin

View File

@ -11,7 +11,7 @@
created Nov 2010 created Nov 2010
by David A. Mellis by David A. Mellis
updated 2 Dec 2010 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
@ -24,7 +24,10 @@ File myFile;
void setup() void setup()
{ {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.print("Initializing SD card..."); Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default. // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin // Note that even if it's not used as the CS pin, the hardware SS pin

View File

@ -11,7 +11,7 @@
created Nov 2010 created Nov 2010
by David A. Mellis by David A. Mellis
updated 2 Dec 2010 modified 2 Apr 2012
by Tom Igoe by Tom Igoe
This example code is in the public domain. This example code is in the public domain.
@ -23,7 +23,10 @@ File root;
void setup() void setup()
{ {
// Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
Serial.print("Initializing SD card..."); Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default. // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin // Note that even if it's not used as the CS pin, the hardware SS pin

View File

@ -9,6 +9,7 @@
* TX is digital pin 3 (connect to RX of other device) * TX is digital pin 3 (connect to RX of other device)
created back in the mists of time created back in the mists of time
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
based on Mikal Hart's example based on Mikal Hart's example
@ -21,7 +22,10 @@ SoftwareSerial mySerial(2, 3); // RX, TX
void setup() void setup()
{ {
Serial.begin(57600); // Open serial communications and wait for port to open:
Serial.begin57600;
while(!Serial) ;
Serial.println("Goodnight moon!"); Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port // set the data rate for the SoftwareSerial port

View File

@ -17,6 +17,7 @@
* Second serial device's TX attached to digital pin 4, RX to pin 5 * Second serial device's TX attached to digital pin 4, RX to pin 5
created 18 Apr. 2011 created 18 Apr. 2011
modified 2 Apr 2012
by Tom Igoe by Tom Igoe
based on Mikal Hart's twoPortRXExample based on Mikal Hart's twoPortRXExample
@ -33,8 +34,9 @@ SoftwareSerial portTwo(4, 5);
void setup() void setup()
{ {
// Start the hardware serial port // Open serial communications and wait for port to open:
Serial.begin(9600); Serial.begin(9600);
while(!Serial) ;
// Start each software serial port // Start each software serial port
portOne.begin(9600); portOne.begin(9600);