Skip to content

Commit 970dd04

Browse files
committed
added serial opening mod for Leonardo in examples
1 parent 9c63ffb commit 970dd04

File tree

11 files changed

+55
-21
lines changed

11 files changed

+55
-21
lines changed

WiFi/examples/ConnectNoEncryption/ConnectNoEncryption.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ char ssid[] = "yourNetwork"; // the name of your network
1818
int status = WL_IDLE_STATUS; // the Wifi radio's status
1919

2020
void setup() {
21-
// initialize serial:
22-
Serial.begin(9600);
21+
//Initialize serial and wait for port to open:
22+
Serial.begin(9600);
23+
while (!Serial) {
24+
; // wait for serial port to connect. Needed for Leonardo only
25+
}
2326

2427
// check for the presence of the shield:
2528
if (WiFi.status() == WL_NO_SHIELD) {

WiFi/examples/ConnectWithWEP/ConnectWithWEP.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ int keyIndex = 0; // your network key Index numbe
3030
int status = WL_IDLE_STATUS; // the Wifi radio's status
3131

3232
void setup() {
33-
// initialize serial:
34-
Serial.begin(9600);
33+
//Initialize serial and wait for port to open:
34+
Serial.begin(9600);
35+
while (!Serial) {
36+
; // wait for serial port to connect. Needed for Leonardo only
37+
}
3538

3639
// check for the presence of the shield:
3740
if (WiFi.status() == WL_NO_SHIELD) {

WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ char pass[] = "secretPassword"; // your network password
1919
int status = WL_IDLE_STATUS; // the Wifi radio's status
2020

2121
void setup() {
22-
// initialize serial:
23-
Serial.begin(9600);
22+
//Initialize serial and wait for port to open:
23+
Serial.begin(9600);
24+
while (!Serial) {
25+
; // wait for serial port to connect. Needed for Leonardo only
26+
}
2427

2528
// check for the presence of the shield:
2629
if (WiFi.status() == WL_NO_SHIELD) {

WiFi/examples/ScanNetworks/ScanNetworks.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
#include <WiFi.h>
2020

2121
void setup() {
22-
// initialize serial and wait for the port to open:
23-
Serial.begin(9600);
22+
//Initialize serial and wait for port to open:
23+
Serial.begin(9600);
24+
while (!Serial) {
25+
; // wait for serial port to connect. Needed for Leonardo only
26+
}
2427

2528
// check for the presence of the shield:
2629
if (WiFi.status() == WL_NO_SHIELD) {

WiFi/examples/WifiChatServer/WifiChatServer.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ WiFiServer server(23);
3434
boolean alreadyConnected = false; // whether or not the client was connected previously
3535

3636
void setup() {
37-
// start serial port:
38-
Serial.begin(9600);
37+
//Initialize serial and wait for port to open:
38+
Serial.begin(9600);
39+
while (!Serial) {
40+
; // wait for serial port to connect. Needed for Leonardo only
41+
}
3942

4043
// check for the presence of the shield:
4144
if (WiFi.status() == WL_NO_SHIELD) {

WiFi/examples/WifiCosmClient/WifiCosmClient.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ boolean lastConnected = false; // state of the connection last t
4646
const unsigned long postingInterval = 10*1000; //delay between updates to Cosm.com
4747

4848
void setup() {
49-
// start serial port:
50-
Serial.begin(9600);
49+
//Initialize serial and wait for port to open:
50+
Serial.begin(9600);
51+
while (!Serial) {
52+
; // wait for serial port to connect. Needed for Leonardo only
53+
}
5154

5255
// check for the presence of the shield:
5356
if (WiFi.status() == WL_NO_SHIELD) {

WiFi/examples/WifiCosmClientString/WifiCosmClientString.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ boolean lastConnected = false; // state of the connection last t
5151
const unsigned long postingInterval = 10*1000; //delay between updates to cosm.com
5252

5353
void setup() {
54-
// start serial port:
55-
Serial.begin(9600);
54+
//Initialize serial and wait for port to open:
55+
Serial.begin(9600);
56+
while (!Serial) {
57+
; // wait for serial port to connect. Needed for Leonardo only
58+
}
5659

5760
// check for the presence of the shield:
5861
if (WiFi.status() == WL_NO_SHIELD) {

WiFi/examples/WifiTwitterClient/WifiTwitterClient.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ void setup() {
5050
// reserve space for the strings:
5151
currentLine.reserve(256);
5252
tweet.reserve(150);
53-
// start serial port:
54-
Serial.begin(9600);
53+
//Initialize serial and wait for port to open:
54+
Serial.begin(9600);
55+
while (!Serial) {
56+
; // wait for serial port to connect. Needed for Leonardo only
57+
}
5558

5659
// check for the presence of the shield:
5760
if (WiFi.status() == WL_NO_SHIELD) {

WiFi/examples/WifiWebClient/WifiWebClient.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ IPAddress server(173,194,73,105); // numeric IP for Google (no DNS)
4040
WiFiClient client;
4141

4242
void setup() {
43-
Serial.begin(9600);
43+
//Initialize serial and wait for port to open:
44+
Serial.begin(9600);
45+
while (!Serial) {
46+
; // wait for serial port to connect. Needed for Leonardo only
47+
}
4448

4549
// check for the presence of the shield:
4650
if (WiFi.status() == WL_NO_SHIELD) {

WiFi/examples/WifiWebClientRepeating/WifiWebClientRepeating.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ boolean lastConnected = false; // state of the connection last
3636
const unsigned long postingInterval = 10*1000; // delay between updates, in milliseconds
3737

3838
void setup() {
39-
// start serial port:
40-
Serial.begin(9600);
39+
//Initialize serial and wait for port to open:
40+
Serial.begin(9600);
41+
while (!Serial) {
42+
; // wait for serial port to connect. Needed for Leonardo only
43+
}
4144

4245
// check for the presence of the shield:
4346
if (WiFi.status() == WL_NO_SHIELD) {

WiFi/examples/WifiWebServer/WifiWebServer.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ int status = WL_IDLE_STATUS;
2929
WiFiServer server(80);
3030

3131
void setup() {
32-
// start serial port:
33-
Serial.begin(9600);
32+
//Initialize serial and wait for port to open:
33+
Serial.begin(9600);
34+
while (!Serial) {
35+
; // wait for serial port to connect. Needed for Leonardo only
36+
}
3437

3538
// check for the presence of the shield:
3639
if (WiFi.status() == WL_NO_SHIELD) {

0 commit comments

Comments
 (0)