
The example below shows how to connect to a WEP encrypted network named "yourNetwork" with a
hex key of "ABBADEAF01", and a key index of 0.
#include <WiFi.h>
char
ssid[] =
"yourNetwork"
;
// your network SSID (name)
char
key[] =
"ABBADEAF01"
;
// your network key
int
keyIndex = 0;
//your network key Index number
int
status = WL_IDLE_STATUS;
// the Wifi radio's status
void
setup
() {
// initialize serial:
Serial
.
begin
(9600);
// attempt to connect using WEP encryption:
Serial
.
println
(
"Attempting to connect to WEP network..."
);
status = WiFi.
begin
(ssid, keyIndex, key);
// if you're not connected, stop here:
if
( status != WL_CONNECTED) {
Serial
.
println
(
"Couldn't get a wifi connection"
);
while
(
true
);
}
// if you are connected, print out info about the connection:
else
{
Serial
.
println
(
"Connected to network"
);
}
}
void
loop
() {
// do nothing
}
SD Card and SPI
The WiFI Shield includes a micro-SD card slot, which can be interfaced with using the
SD library
.
The SS for the SD card is pin 4.
Arduino communicates with the shield using the SPI bus. This is on digital pins 11, 12, and 13 on the
Uno and pins 50, 51, and 52 on the Mega. On both boards, pin 10 is used as SS. On the Mega, the
hardware SS pin, 53, is not used, but it must be kept as an output or the SPI interface won't work.
Updating firmware on the shield
Please follow
this guide
to update the firmware on your shield.
Next steps
Refer to the
WiFi library page
for more information on the functionality of the shield, as well as
further examples.
Summary of Contents for WiFI Shield
Page 4: ...Ports on the WiFi Shield ...