mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-22 08:22:04 +03:00
Changed examples to include shield detection
This commit is contained in:
@ -14,7 +14,7 @@
|
||||
|
||||
created 18 Dec 2009
|
||||
by David A. Mellis
|
||||
modified 23 Apr 2012
|
||||
modified 31 May 2012
|
||||
by Tom Igoe
|
||||
|
||||
*/
|
||||
@ -22,8 +22,8 @@
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "YourNetwork"; // your network SSID (name)
|
||||
char pass[] = "password"; // your network password (use for WPA, or use as key for WEP)
|
||||
char ssid[] = "yourNetwork"; // your network SSID (name)
|
||||
char pass[] = "secretPassword"; // your network password (use for WPA, or use as key for WEP)
|
||||
|
||||
int keyIndex = 0; // your network key Index number (needed only for WEP)
|
||||
|
||||
@ -36,16 +36,21 @@ boolean alreadyConnected = false; // whether or not the client was connected pre
|
||||
void setup() {
|
||||
// start serial port:
|
||||
Serial.begin(9600);
|
||||
|
||||
|
||||
// check for the presence of the shield:
|
||||
if (WiFi.status() == WL_NO_SHIELD) {
|
||||
Serial.println("WiFi shield not present");
|
||||
// don't continue:
|
||||
while(true);
|
||||
}
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
Serial.println(ssid);
|
||||
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
|
||||
status = WiFi.begin(ssid, pass);
|
||||
if ( status != WL_CONNECTED) {
|
||||
Serial.println("Couldn't get a wifi connection");
|
||||
while(true);
|
||||
}
|
||||
|
||||
// wait 10 seconds for connection:
|
||||
delay(10000);
|
||||
}
|
||||
|
Reference in New Issue
Block a user