Instructables

Arduino Webserver Control Lights, Relays, Servos, etc...

Featured
Picture of Arduino Webserver Control Lights, Relays, Servos, etc...
Untitled.png
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..

Overview:

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: “http://192.168.1.178/?button1on” the arduino will read that information and It turns the LED On.

By default the IP is “192.168.1.178″. 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)


 
Remove these adsRemove these ads by Signing Up

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!
JCL229 days ago

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.

alftonic2 months ago

Hello:

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

Hello,some question

what would happen if the connection to the webserves is a Shield 3g ? Can do it?

A greeting and thanks

sbirk5 months ago

Hi RUI,

Nice project there..:D

I have a yun so I wuold like to make it wireless..:D I replaced all the Ethernet with the wifi webserver.. and got connected ...

I can enter the local page with the bottuns (pc and mac) but when I try the buttons it goes to the setup page instead on turning the led on...

My code: http://goodworkmyboy.dk/test_wifi_led.txt

Hope you can help...

chrisleva sbirk4 months ago

I have a Yun with a Seeed Relay Shield. I'm trying to get a garage door opener sketch. I discovered the webserver piece can run inside Linux on the Yun but need help with everything else.

marslan25 months ago


your project is very good that I admire .
I used to arduino leonardo . I want to make this project. but I dont know arduino leonardo with ethernet shield can use. it is possible ?
best regards

Akash jaiswal10 months ago

Hey RUI.....i m a noob wrt comps and it engg.....i jst wanna knw " can we include more buttons on server so that we can control more no of loads on arduino "

I believe that any HTML editor can do it, since the code just passes an intruction trhu the web. For instance, if you want to turn on other led, just create an HTML button for this other led that passes on a "turn on" instruction for this same led, got it?

See some HTML tutorials here http://www.w3schools.com/

Thankzz Raphango... i got it....

You are welcome! ^^

Raphango10 months ago

Definetely gotta do it! =D

Thanks a lot!!!! =DDD

jmance110 months ago
can this be made using some wifi shield instead of ethernet?
RuiSantos (author)  jmance110 months ago
Yes! Definitely, you just need to make a few changes...
I would start by taking a look at the Arduino Examples from the WiFi library.
And see how WiFiWebserver example works...
I hope this helps.

(Those examples I'm talking about can be found on the Arduino IDE)
tamberg11 months ago

Hi Rui, great project. To access the Web UI from everywhere you might want to try our YalerEthernetServer library (see http://yaler.net/arduino). Just downloaded and adapted your code, seems to work fine. Kind regards, Thomas

tgathright11 months ago

Hello, My Ethernet shield is a Arduino R3 version, is it suppose to work with the code with this instructable?

Thanks,

TG

RuiSantos (author)  tgathright11 months ago
yeah it should work just fine.
As your shield uses the exact same chip as mine...
Wiznet W5100
leorivas11 months ago
Hi
I did everything as in the tutorial, but I cant see the webpage, when I connect the serial monitor, it only says: server is at 0.0.0.0
What am I doing wrong? the software compiled without errors, tried with a set of IP addresses vlaid for my network, the router litght blinks so I think the board is alive and there is connection.
Thanks a lot
Leo
leorivas leorivas11 months ago
Sorry. The configuration is Arduino UNO and Ethernet Shield V1.1.

Thanks
RuiSantos (author)  leorivas11 months ago
I'm glad you found the solution!
Have a nice day,
Rui
leorivas RuiSantos11 months ago
Hi Rui
Well, it still does not work, I was just telling about the hardware configuration.
Btw, I noticed that the ethenet shield you got there looks different than mine (V1.1). Managed to download a driver and put some sample code in, and it worked. But as far as I could analyze the code, it does not use the 'Ethernet.h' include, but 'etherShield.h', the rest of the code looks very 'hardware-oriented', with buffers and pointers and stuff, not at all as simple as your code looks.
I guess, it is a ethershield hardware version problem. Can you suggest a ethershield model, or you think it is possible to make your sketch to work with this one?

Thanks again
Leo
leorivas leorivas11 months ago

Hello Rui, I am back with my research, it might be useful for others.

What happened here, is that there are two types of ethernet shield, one based with the ENC28J60 chip, and another with the Wiznet W5100, which is the one supported by the default ethernet arduino library (the one you used).

Unfortunately, mine is the ENC28J60 based, and uses a different library, so a different way to program. So far I found two libs (actually three):

EtherShield:http://blog.thiseldo.co.uk/?p=329 , this one is outdated and it looks out of support. I am sure it still works, but I discarded it. This is the one I had, with very hardware oriented looking code (byte oriented buffers, hex args, pointers, etc, even the simple webserver code looks pretty much unreadable compared to the one written with other libs).

EtherCard: https://github.com/jcw/ethercard , still supported, managed to run some example sketches succesfully. Waaay simpler to read than the previous one.

UIPEthernet: https://github.com/ntruchsess/arduino_uip , this one works as a wrapper to make 'Ethernet.h' code work like this project, replacing it with 'UIPEthernet.h". Cool!

Unfortunately, though I managed your sketch code to work on the ENC28J60 using the UIPEthernet, the arduino hardware hanged pretty often, I mean, the led could be turned ON, or the servo moved, but then it stopped responding to web requests. Sad.

What I will try now is try to adapt your code, but using the EtherCard, so people using this ethernet shield can run your project.

Thanks for listening

Leo


RuiSantos (author)  leorivas11 months ago

Hi Leo,

Unfortunately I don't own a shield with ENC28J60 chip. So I can't make it compatible with that board, as I don't have a way to test it.

I'll update the parts list from my instructable so people don't have that problem too! Thanks for poiting that out.

I hope you can make it work with your board properly.

Have a nice day,

Rui

DSAVARD00211 months ago
I would like to buy it, without leds. It is possible ?
I was looking for something like this !

Dany
RuiSantos (author)  DSAVARD00211 months ago
what you mean by buy it without leds?
You can find everything on amazon for example...
you don't need to buy the LED's this is just an example :)
(removed by author or community request)
RuiSantos (author)  DELETED_DELETED_CDCosma11 months ago
To be honest with you I don't remember.
They look really similar so I think I had used that CSS...
but I think I found this information in a blog... not in insctructables.
This project is almost one year old but I've only decided to post it a few months ago on my blog, and this weekend on instructables
(removed by author or community request)
RuiSantos (author)  DELETED_DELETED_CDCosma11 months ago
I've tried to search for almost an hour but I don't remember where :S it was almost a year ago... If I'll find I'll let you know!
alexmac13111 months ago
for the price of the shields and such a raspberry pi is better and then use then pi to control the arduino through nodejs and Johnny give
RuiSantos (author)  alexmac13111 months ago
Hi,
yes the Raspberry Pi can be also a good option... the BeagleBone is even better than the Rpi though.
It all depends where you buy your products from... the Raspberry Pi is way more expensive to setup than an Arduino and Ethernet shield (you can get a clone for $12)