Introduction: Arduino Webserver Control Lights, Relays, Servos, Etc...

Picture of Arduino Webserver Control Lights, Relays, Servos, Etc...
In this project using only an Arduino with an Ethernet shield.
I’ll be controlling one LED and a servo, but you can apply this method to control a DC motors, buzzers, relays, stepper motors, etc..


When you upload the the code provided in this tutorials. it creates a webserver in your LAN and you simply use the IP to access that webserver through your browser. After that it shows a webpage similar to that one below. When you press the button “Turn On LED” your url will change to: “” the arduino will read that information and It turns the LED On.

By default the IP is “″. That also can be found on the Arduino code provided.
The Webpage will look like the image on the attachments.

Check this Video tutorial below ! (Includes demonstration)

Step 1: Parts Required

Picture of Parts Required
  • 1x Arduino Uno
  • 1x Ethernet Shield (with Wiznet W5100 chip)
  • 1x 220 Ohm Resistor
  • 1x LED
  • 1x Micro Servo Motor
  • 1x Breadboard
  • Jumper Cables

Step 2: Schematics

Picture of Schematics

Simply follow the schematics.

Step 3: Upload This Arduino Code Below:

Picture of Upload This Arduino Code Below:

Step 4: Final Step

Picture of Final Step
It's done! If you didn't watch the youtube video yet, make sure you watch now. Not only to see the video demonstration, but you can also find more information that might help you finish this Instructable.

Now you can create your own webserver! 
And control any electronic device you desire.

Did you enjoyed this project?
Please support my work by sharing this project with a friend!

Make sure you follow me on instructables so you don't miss my next project!

Have a problem?
Leave a comment below and I'll help you :)

P.S. Click here to see my blog where I post weekly Projects and Electronics Tips!


hadisamani (author)2017-10-06

hello sir
i connected to nudemcu and control it with routor network
but i want control it with 4g...
how i can do it?
thank you for nice code and nice guide:)

ΓιώργοςΚ9 (author)2017-09-12



EgaN4 (author)2017-03-12

Great job, I just wondering once Arduino programed, is USB connection still needed or it can be controlled just by network cable over web?, thanks

Maruf93 (author)2017-02-09

Why It's not working???

ryankim08 (author)2017-02-06

i didn't work. I m using an ethernet module is it the same as ethernet shield?

PatrickL139 (author)2016-10-25

Yeah, I made it.

Is it possible to add the LED light status on the website?

Many thanks!

MuzammilT (author)PatrickL1392016-12-27

can u send me this project code to my mail

HridoyK3 (author)2016-10-23

What the program does not need this project? The program will please anyone.

AlvianP (author)2016-10-09

hey, very nice project !

can i do this with ENC28J60?

its basically has the same eternet function but i dont know which line code i should change to make this works, thanks in advance

Balu_Sk (author)2016-10-08

Hi.. I have to add more buttons and readings on the page. I know there will no enough space in the arduino. How can I modify this code and host the page in SD card.

mohamadhassan (author)2016-09-19

Hi, if we want to access the arduino over the internet, what we we have to do ?
thanks in advance

TomH164 (author)2016-06-05

Do you need to be on the same Internet connection to use this?

fefrie (author)TomH1642016-06-08

No you can use your home ip and foward ports to port 80 on the arduino

WesleyS34 (author)fefrie2016-07-06

Super helpful, thank you!! I've always wondered how to control the MKR1000 from the web, this seems like a great way! Is it possible to put a login on Port 80 for security? Is that somewhere in my router settings?

SalmanM16 (author)2016-06-19

i am controll home automation system though web kindly guide me how am done it?.how am create own web server and connected with them

SalmanM16 (author)2016-06-19

i am controll home automation system though web kindly guide me how am done it?.how am create own web server and connected with them

ggogail (author)2016-06-10

Hello ,

I've copy your code but it doesn't work when i press on a button into the web page the url write myIP/?button1on but the arduino don't change the step of my LED .

What the problem ?

Cristóbal AndrésN (author)2016-04-25

hi.... i have a problem respect to my ethernet shield arduino...when i conect to my notebook and assing a IP ......this board give me this messaje "server is at" i dont know how fix this problem .... can you give help? i from chile... this is my email

Did you assign an unused Mac address?

jerryar (author)2016-05-15

Hello, Could someone help with accessing the page with the On/Off buttons.I have installed the sketch and the serial monitor shows that the server is at the correct IP address but when I try to access that address with my browser, the request times out without showing the webpage.

Add-Man (author)2016-04-21

Congrats on a great tutorial, very nice work. I got it up and running in minutes, thanks!

ron4stoppable made it! (author)2016-02-29

nice work on the webpage, quite simple and clean code, thanks a lot

PavanO1 (author)2016-02-10

Help me to add multiple Buttons please.

I am trying this project for Home Automation using 8 Channel Relay.

So I need 8 on/off buttons. Please help.

fefrie (author)2016-02-03

It works perfect as displayed.

I'm trying to make it so that when I press the button1on, it turns the relay on for a set period of time, then turn off automatically. It works with a delay; followed by a LOW command, but while still on, the button1off button is basically useless, and pressing the button1on button makes it turn on for multiples of whatever I set the delay at. Any suggestions?

I need some sort of maxdelay(10000) command for button1on and some sort of override or delay(0) for button1off

if (readString.indexOf("?button1on") >0){
digitalWrite(led, HIGH);
digitalWrite(led, LOW);
if (readString.indexOf("?button1off") >0){
digitalWrite(led, LOW);

Rb22 (author)2016-01-04

Hey, Your program works perfectly. But I encounter some problem when I tried to connect using my phone a different net work. So does that mean you only can control the arduino under the same network?

hrithikbansal70 (author)Rb222016-01-31

I think so, since he only made a local server

havatoke (author)Rb222016-01-11

Make sure you have your router set up to port forward the port your using. I think it was 80 in the sketch. Then you'll have to use your "external" IP address. Google "what's my ip address "

Good luck

bronston (author)havatoke2016-01-21

If you do open the port to the internet I wouldn't recommend putting anything to important on there as anyone with internet access would be able to access it if they happen to stumble across your IP.

geminigumisong (author)2016-01-19

can you give me the code

send it here


havatoke (author)2016-01-11

Everything works great! I would like to take this to the next level for my needs but I'm dumb on the subject. What I'm trying to do is use IFTTT maker channel to trigger this button push when I'm within the defined area. It asks for some info to complete the recipe but again. .. duhh on this end. I set up a port forword already and am able to turn it on and off with 4g using the website.

It asks for a url, I plugged in my external with : port#

A method, the options are;


Content Type, options are;

Application/JSON, Application/x-www-form-urlencoded and text/plain

Then the last thing it wants is body

Any help would be greatly appreciate!

rossp1987 (author)2015-12-17

hello great build really simple to follow my only problem is that the url only works once, so i can turn on the led the the webpage fails so i have to restart the arduino access the webpage and it turns off again

Poelemoel made it! (author)2015-11-18

Thanks for this great tutorial. It works ;-)

I only wonder why the reaction of the buttons is really slow. When you press a button it takes almost a second for both the led and the servo to react...

Ashen Chandrasiri (author)2015-10-06


i did upload the sketch and went to given ip address, but it didn't load at all. when i open the serial monitor, it say "server is at"

only difference is i used a Ethernet module instead of shield.

i tried examples from EtherCard library, and they seems working. but when it comes to Ethernet library, something is wrong. HELP me!!

Go here and get the UIPE library its the one most used for modules.

Install it and then close your IDE. Re-open the IDE and load up the sketch. Delete the line that reads

#include <Ethernet.h>

now insert a new line that reads

#include <UIPEthernet.h>

Thats all thats needed as you are probably using the ENC28J60 based module

PiotrS (author)Ashen Chandrasiri2015-10-16

when you uploading unplug the ethernet shield first after upload complit disconect the usb cable plug the ethernet shieald and conect the usb shuld work

AquaM (author)2015-08-08

Hello, i was wondering how you would go about changing the colours of the buttons (Turn on LED, etc.) on the website? I have been trying to learn how to use html and was wondering how how to do it.Any assistance would be greatly appreciated! Thanks

PiotrS (author)AquaM2015-10-16

he is using css sheat in this example wich is located on his serwer it is the line

client.println("<link rel='stylesheet' type='text/css' href='' />");

you could makeke your own css stylesheat put it on some server and just chang the addres in this line

PiotrS (author)2015-10-16

hi i hav a question for u im using RTC clock so iv added buttons to set the clock i also added a line in html to refresh the site once every seckend but i have encounter a problem it remembers last button iv prest and it just repeats it so if i pres a button to ad 1houer to the clack it is adding them contyniuesly

this is the line i have added to refresh

client.println("<meta http-equiv='Refresh' content='1'/>");

and this is one of the buttons to set the time (it is adding 1 houer)

if (readString.indexOf("?h+") >0){

s = rtc.getSecond();

m = rtc.getMinute();

h = rtc.getHour();


if (h>23){h=0;}

rtc.setTime(h, m, s);


the addres of my site is

but after a button pres it is contyniuesly refreshing the new adrres

and keaps adding houers help plizz

AlexandreD11 (author)2015-09-25

I start arduino as webserver and i found this project .
when i look at the code i can see :



is it an obligation to put line by line string to output or can i do




within string length limitation of arduino memory

(with no "ln" or \n because blank space are normalized in html viewer )

thank for the answer

joon874 (author)2015-08-05

Hello, RuiSantos

I am an engineer in WIZnet which designed Ethernet chip you used as Ethernet shield.

Could I introduce your great project to WIZnet blog to share the idea for other makers??

It will be so hlepful!!

Thank you!


javier.d.palma.3 (author)2015-06-24

i love it!, it is so simple y great

SaifK2 (author)2015-06-05

Was able to make one working. But there is a problem when i connect load to relay than my arduino webserver stops responding

david.j.wentworth (author)2015-04-18

ive been searching for days for something like this the only differance is i would like to use a wifi shield any help on what i would need to change?

diegocaetano1988 (author)2015-03-15

whats ports on arduino ? thanks great tutorial

iNananOhhYeahh (author)2015-03-13

server is at

Please help..

marcelo.benitez1 (author)2015-03-10


noel.kuck (author)2015-02-12

Not able to connect via the server address(es) in the sketch or from the serial monitor. Ideas?

rien.schouten.98 (author)2014-12-22

thanks for the code!

i modified it so i can control my 433mhz remote wall sockets with the newremoteswitch library. i used a clone uno r3 with unofficial ethernet shield.

JCL2 (author)2014-11-20

Good day Sir!
I was wondering if ever i could make the servo rotate continuously? Because I'm planning to make a wheel for a simple robotic car. Is there any changes that i will make on the program or i will have to use continuous servos. I'm trying to make one but it only rotates on 180. I'm using Tower Pro SG-5010 servos.
Hope you could reply.

alftonic (author)2014-10-08


Please.... how can I stop rotate after turn 360°?

About This Instructable




Bio: Author, Blogger, Electronics Enthusiast and Entrepreneur. For complete Electronics Projects and Tutorials go to:
More by RuiSantos:ESP8266 Web Server (Without Arduino)Arduino Simple Memory GameArduino – Datalogger with Temperature Sensor and Photoresistor
Add instructable to: