Download Print this page

Arduino WiFI Shield Manual page 9

Advertisement

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";
char
key[] = "ABBADEAF01";
int
keyIndex = 0;
int
status = WL_IDLE_STATUS;
void
setup() {
// initialize serial:
Serial.begin(9600);
// attempt to connect using WEP encryption:
Serial.println("Attempting to connect to WEP
status = WiFi.begin(ssid, keyIndex, key);
// if you're not connected, stop here:
if
( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi
while(true);
}
// if you are connected, print out info about the connection:
else
{
Serial.println("Connected to
}
}
void
loop() {
// do nothing
}
SD Card and SPI
The WiFI Shield includes a micro-SD card slot, which can be interfaced with using the
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
Next steps
Refer to the
WiFi library page
further examples.
//
your network SSID (name)
// your network key
//your network key Index number
// the Wifi radio's status
connection");
network");
to update the firmware on your shield.
for more information on the functionality of the shield, as well as
network...");
SD
library.

Advertisement

loading
Need help?

Need help?

Do you have a question about the WiFI Shield and is the answer not in the manual?

Subscribe to Our Youtube Channel