loading
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)


Step 1: 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
<p>Hello</p><p>Sory for my bad english</p><p>I want to turn on the led when analog input A0 &gt; 1 and stay on even if page is refresh.</p><p>i try this </p><p> //controls the Arduino if you press the buttons</p><p> if ( voltage*11.16 &lt; 11.2){</p><p> digitalWrite(led, HIGH);</p><p> }</p><p> if (readString.indexOf(&quot;?button1on&quot;) &gt;0){</p><p> digitalWrite(led, HIGH);</p><p> }</p><p> if (readString.indexOf(&quot;?button1off&quot;) &gt;0){</p><p> digitalWrite(led, LOW);</p><p> } </p><p>but when voltage*11.16&gt;11.2 led turn of .</p><p> thank you</p>
Do you need to be on the same Internet connection to use this?
<p>No you can use your home ip and foward ports to port 80 on the arduino</p>
<p>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?</p>
<p>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</p>
<p>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</p>
<p>Hello , </p><p>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 .</p><p>What the problem ?</p>
<p>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 &quot;server is at 0.0.0.0&quot; i dont know how fix this problem .... can you give help? i from chile... this is my email cristobalnieto93@gmail.com </p>
<p>Did you assign an unused Mac address?</p>
<p>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.</p>
<p>Congrats on a great tutorial, very nice work. I got it up and running in minutes, thanks!</p>
<p>nice work on the webpage, quite simple and clean code, thanks a lot</p>
<p>Help me to add multiple Buttons please.</p><p>I am trying this project for Home Automation using 8 Channel Relay. </p><p>So I need 8 on/off buttons. Please help.</p>
<p>It works perfect as displayed.</p><p>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?</p><p>I need some sort of maxdelay(10000) command for button1on and some sort of override or delay(0) for button1off</p><p> if (readString.indexOf(&quot;?button1on&quot;) &gt;0){<br> digitalWrite(led, HIGH);<br> delay(10000);<br> digitalWrite(led, LOW);<br> }<br> if (readString.indexOf(&quot;?button1off&quot;) &gt;0){<br> digitalWrite(led, LOW);</p>
<p>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?</p>
I think so, since he only made a local server
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 &quot;external&quot; IP address. Google &quot;what's my ip address &quot;<br><br>Good luck
<p>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.</p>
<p>can you give me the code</p><p>send it here geminigumisong@gmail.com </p><p>thanks</p>
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.<br><br><br>It asks for a url, I plugged in my external with : port#<br><br>A method, the options are; <br><br>GET, POST, PUT, HEAD, DELETE, PATCH and OPTIONS<br><br>Content Type, options are; <br><br>Application/JSON, Application/x-www-form-urlencoded and text/plain<br><br>Then the last thing it wants is body<br><br>Any help would be greatly appreciate!<br><br><br><br><br><br><br>
<p>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</p>
<p>Thanks for this great tutorial. It works ;-)</p><p>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...</p>
<p>Hi,</p><p> 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 &quot;server is at 0.0.0.0&quot; </p><p>only difference is i used a Ethernet module instead of shield.</p><p>i tried examples from EtherCard library, and they seems working. but when it comes to Ethernet library, something is wrong. HELP me!!</p>
<p>Go here and get the UIPE library its the one most used for modules.</p><p><a href="http://www.tweaking4all.com/hardware/arduino/arduino-enc28j60-ethernet/" rel="nofollow">http://www.tweaking4all.com/hardware/arduino/ardui...</a></p><p>Install it and then close your IDE. Re-open the IDE and load up the sketch. Delete the line that reads </p><p>#include &lt;Ethernet.h&gt;</p><p>now insert a new line that reads</p><p>#include &lt;UIPEthernet.h&gt;</p><p>Thats all thats needed as you are probably using the ENC28J60 based module</p>
<p>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</p>
<p>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</p>
<p>he is using css sheat in this example wich is located on his serwer it is the line </p><p>client.println(&quot;&lt;link rel='stylesheet' type='text/css' href='http://randomnerdtutorials.com/ethernetcss.css' /&gt;&quot;);</p><p>you could makeke your own css stylesheat put it on some server and just chang the addres in this line</p>
<p>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 </p><p>this is the line i have added to refresh </p><p>client.println(&quot;&lt;meta http-equiv='Refresh' content='1'/&gt;&quot;);</p><p>and this is one of the buttons to set the time (it is adding 1 houer)</p><p>if (readString.indexOf(&quot;?h+&quot;) &gt;0){</p><p> s = rtc.getSecond();</p><p> m = rtc.getMinute();</p><p> h = rtc.getHour();</p><p> h=h+1;</p><p> if (h&gt;23){h=0;}</p><p> rtc.setTime(h, m, s);</p><p> }</p><p>the addres of my site is 192.168.1.178</p><p>but after a button pres it is contyniuesly refreshing the new adrres </p><p>192.168.1.178/?h+</p><p>and keaps adding houers help plizz</p>
<p>Hi<br>I start arduino as webserver and i found this project .<br>when i look at the code i can see :</p><p> client.println(&quot;&lt;HTML&gt;&quot;);</p><p> client.println(&quot;&lt;HEAD&gt;&quot;);</p><p>is it an obligation to put line by line string to output or can i do <br><br>client.println(&quot;&lt;HTML&gt;\n&lt;HEAD&gt;&quot;); <br><br>or <br><br>client.print(&quot;&lt;HTML&gt;&lt;HEAD&gt;&quot;);</p><p><br>within string length limitation of arduino memory <br><br>(with no &quot;ln&quot; or \n because blank space are normalized in html viewer ) </p><p>thank for the answer </p>
<p>Hello, RuiSantos</p><p>I am an engineer in WIZnet which designed Ethernet chip you used as Ethernet shield.</p><p>Could I introduce your great project to WIZnet blog to share the idea for other makers??</p><p>It will be so hlepful!!</p><p>Thank you!</p><p>Lawrence.</p>
<p>i love it!, it is so simple y great</p>
<p>Was able to make one working. But there is a problem when i connect load to relay than my arduino webserver stops responding </p>
<p>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?</p>
<p>whats ports on arduino ? thanks great tutorial</p>
<p>server is at 0.0.0.0</p><p>Please help..</p>
<p>CONGRATS! VERY GOOD PROJECT!</p>
<p>Not able to connect via the server address(es) in the sketch or from the serial monitor. Ideas?</p>
<p>thanks for the code!</p><p>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. </p>
<p>Good day Sir! <br>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.<br>Hope you could reply.</p>
<p>Hello:</p><p>Please.... how can I stop rotate after turn 360&deg;? </p>
<p>Hello,some question </p><p>what would happen if the connection to the webserves is a Shield 3g ? Can do it? </p><p>A greeting and thanks</p>
<p>Hi RUI,</p><p>Nice project there..:D </p><p>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 ... </p><p>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... </p><p>My code: <a href="http://goodworkmyboy.dk/test_wifi_led.txt" rel="nofollow">http://goodworkmyboy.dk/test_wifi_led.txt</a></p><p>Hope you can help... </p>
<p>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. </p>
<p>hı <br>your project is very good that I admire .<br>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 ? <br>best regards</p>
<p>Hey RUI.....i m a noob wrt comps and it engg.....i jst wanna knw &quot; can we include more buttons on server so that we can control more no of loads on arduino &quot;</p>
<p>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 &quot;turn on&quot; instruction for this same led, got it?</p><p>See some HTML tutorials here http://www.w3schools.com/</p>
<p>Thankzz Raphango... i got it....</p>
<p>You are welcome! ^^</p>
<p>Definetely gotta do it! =D</p><p>Thanks a lot!!!! =DDD</p>
can this be made using some wifi shield instead of ethernet?

About This Instructable

151,325views

841favorites

License:

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