1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +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

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

View File

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

View File

@ -12,6 +12,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 21 May 2011
modified 2 Apr 2012
by Tom Igoe
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
void setup() {
// open the serial port
// Open serial communications and wait for port to open:
Serial.begin(9600);
while(!Serial) ;
// start the Ethernet connection:
Serial.println("Trying to get an IP address using DHCP");
if (Ethernet.begin(mac) == 0) {

View File

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

View File

@ -16,7 +16,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 15 March 2010
updated 16 Mar 2012
modified 2 Apr 2012
by Tom Igoe with input from Usman Haque and Joe Saavedra
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
void setup() {
// start serial port:
// Open serial communications and wait for port to open:
Serial.begin(9600);
while(!Serial) ;
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");

View File

@ -18,7 +18,7 @@
* Ethernet shield attached to pins 10, 11, 12, 13
created 15 March 2010
updated 16 Mar 2012
modified 2 Apr 2012
by Tom Igoe with input from Usman Haque and Joe Saavedra
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
void setup() {
// start serial port:
// Open serial communications and wait for port to open:
Serial.begin(9600);
while(!Serial) ;
// give the ethernet module time to boot up:
delay(1000);
// start the Ethernet connection:

View File

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

View File

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

View File

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

View File

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

View File

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