Introduction: Controlling an LED With Arduino and Wifly Shield

To demonstrate how you can control devices via wifi using the arduino wifly shield, I will switch on and off an LED by sending a http request from my web browser to the wifly shield.


1. Arduino uno

2. Wifly shield

3. Led

4. 220ohm Resistor

5. A couple of jumper wires

The set up is as shown in the picture above.

Step 1: Implementation

After setting up, it is time for you to upload the code. There are two ways you can go about it.

1. Use the wifly shield as a wifi hotspot

2. Join an existing wifi network using the wifly shield

Step 2: 1. Use the Wifly Shield As a Wifi Hotspot

In this case you need to configure the wifly shield as a hotspot then upload the code i have attached here.

Step 3: 2. Join an Existing Wifi Network Using the Wifly Shield

Here you will set the wifly shield to join a wifi hotspot using the serial monitor, or code. After setting the wifly shield using the serial monitor, upload the same code that you used when using the wifly shield as a hotspot (the previous above).

Instead of using the serial monitor to join to the wifly shield to a wifi hotspot, you can use code. To do so, upload the sketch below.

Step 4: Controlling the LED

After uploading the code, open the serial monitor and wait for the wifly shield to start its own hotspot or connect to the hotspot you have specified. The serial monitor will show you the ip address of the wifli shield.

Connect your computer or smartphone to the wifi hotspot your wifly shield is connected to, and enter on your web browser the WiFly shield IP address displayed on the serial monitor followed by /$1# (to switch LED off) or /$2# (to switch led on). So, in my case its$1# and$2# respectively.

Step 5:

If you have used the WiFly shield to create a wifi hotspot, you will have to change the IP address of your computer’s Wifi adapter. Steps on how to do that are described in this link.

In my case I changed mine to since my wifly shield’s IP address was
Then switch on and off the LED the same way you did above, replacing the IP address with the one displayed on the serial monitor.

Step 6:

Now you will be able to control an LED with arduino and a wifly shield. Apart from switching on an LED, you can also control bigger devices using a relay. Therefore, think of some cool things you can do with this and try them out.


DaleH52 (author)2016-09-26

Sir can i use any wifi shield instead of wifly ?thanks


Very helpful!

About This Instructable




Bio: I am an electrical engineer and an Arduino and electronics enthusiasts. I believe working with electricity should be fun as well as beneficial to engineers ... More »
More by yhtomitsy:RFduino - Sending and Receiving Data Via BLE Arduino redback simple serverConfiguring xBee in API mode
Add instructable to: