mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-02 13:24:12 +01:00
Added Serial open check for Leonardo to ScanNetworks example
This commit is contained in:
parent
28da3b1d38
commit
5e9c956338
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
created 13 July 2010
|
created 13 July 2010
|
||||||
by dlf (Metodo2 srl)
|
by dlf (Metodo2 srl)
|
||||||
modified 12 Mar 2012
|
modified 2 April 2012
|
||||||
by Tom Igoe
|
by Tom Igoe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -19,8 +19,9 @@
|
|||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// initialize serial:
|
// initialize serial and wait for the port to open:
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
while(!Serial) ;
|
||||||
|
|
||||||
// attempt to connect using WEP encryption:
|
// attempt to connect using WEP encryption:
|
||||||
Serial.println("Initializing Wifi...");
|
Serial.println("Initializing Wifi...");
|
||||||
@ -41,7 +42,7 @@ void loop() {
|
|||||||
void printMacAddress() {
|
void printMacAddress() {
|
||||||
// the MAC address of your Wifi shield
|
// the MAC address of your Wifi shield
|
||||||
byte mac[6];
|
byte mac[6];
|
||||||
|
|
||||||
// print your MAC address:
|
// print your MAC address:
|
||||||
WiFi.macAddress(mac);
|
WiFi.macAddress(mac);
|
||||||
Serial.print("MAC: ");
|
Serial.print("MAC: ");
|
||||||
@ -66,7 +67,7 @@ void listNetworks() {
|
|||||||
// print the list of networks seen:
|
// print the list of networks seen:
|
||||||
Serial.print("number of available networks:");
|
Serial.print("number of available networks:");
|
||||||
Serial.println(numSsid);
|
Serial.println(numSsid);
|
||||||
|
|
||||||
// print the network number and name for each network found:
|
// print the network number and name for each network found:
|
||||||
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
|
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
|
||||||
Serial.print(thisNet);
|
Serial.print(thisNet);
|
||||||
@ -81,3 +82,4 @@ void listNetworks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user