Easy Basic Arduino Ethernet Controller





Introduction: Easy Basic Arduino Ethernet Controller

I recently went out and bought an Arduino Ethernet Shield but couldnt really put it to use as i couldnt find any easy tutorials so i started to try to code by myself.I was able to come up with a simple section of code which turned on a LED from your internet broweser.Unfortunatly so far i have not been able to control the LED from outside of my home network.

Step 1: Parts

An Arduino
An Arduino Ethernet Shield
A Breadboard
Connecting Wires
An Ethernet cable 

Step 2: Initial Hardware Set Up

If you have one of the newer Arduino Ethernet Shields,it will come with the Mac Address writen on the back of it.
Write that down seperatly before attaching your Shield to the Arduino Board.

To set up,just plug in the header pins from the shield into your Arduino.

Use the ethernet cable to conect your Arduino Ethernet Shield to your Network via your Router.

Note that The Ethernet shield is attached to pins 10, 11, 12, 13 so those cannot be used.

Connect the Positive end of the LED on a breadboard and in turn to Pin 8 and the negative end of the LED to Ground on the Ethernet shield.

Step 3: Acquiring the Basic Info (MAC Address,IP Address,Port Number)

If you have one of the newer Shields it should come with the Mac adress written on the back.

The IP address will be dependent on your local network and to find that out you can use Comamnd Promt.
Open up command promt and type in "ipconfig"

It should then show you your IP Address,default gateway and your subnet mask

You will also need the port you want to use.Port 80 is default for HTTP but since my internet provider had it blocked i ended up using port 8081.

Step 4:

  Web Server
A simple web server
* Ethernet shield attached to pins 10, 11, 12, 13
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0x48, 0xD3 };

// The IP address will be dependent on your local network:
// assign an IP address for the controller:

IPAddress ip(192,168,1,20);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255, 255, 255, 0);

// Initialize the Ethernet server library with the port you want to use.
EthernetServer server(8081);
String readString;
// Any extra codes for Declaration :

// Declare Pin 8 as an LED because thats what we will be connecting the LED to.You could use any other pin and would then have to change the pin number.
int led = 8;

void setup()

// Extra Set up code:
pinMode(led, OUTPUT); //pin selected to control

//enable serial data print

  //start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
  Serial.print("Server is at ");
  Serial.println("LED Controller Test 1.0");

void loop()
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client)

    Serial.println("new client");

    while (client.connected())
      if (client.available())

        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100)


          //store characters to string
          readString += c;

          // if you've gotten to the end of the line (received a newline
          // character) and the line is blank, the http request has ended,
          // so you can send a reply
          //if HTTP request has ended
          if (c == '\n') {
            Serial.println(readString); //print to serial monitor for debuging
// Needed to Display Site:
client.println("HTTP/1.1 200 OK"); //send new page
            client.println("Content-Type: text/html");


// what is being Displayed :     
            client.println("<TITLE>Home Automation</TITLE>");
            client.println("<H1>Home Automation</H1>");
            client.println("<hr />");

            client.println("<a href=\"/?lighton\"\">Turn On Light</a>");
            client.println("<br />");
            client.println("<br />");
            client.println("<a href=\"/?lightoff\"\">Turn Off Light</a><br />");     


            //stopping client

            // Code which needs to be Implemented:
            if(readString.indexOf("?lighton") >0)//checks for on
              digitalWrite(8, HIGH);    // set pin 8 high
              Serial.println("Led On");
              if(readString.indexOf("?lightoff") >0)//checks for off
                digitalWrite(8, LOW);    // set pin 8 low
                Serial.println("Led Off");
            //clearing string for next read

            // give the web browser time to receive the data
            // close the connection:
            Serial.println("client disonnected");


Step 5: Feedback

Try the steps and see if it works out if it doesnt work i will try to figure out what went wrong and do leaves comments so i can improve.

2 People Made This Project!


  • Epilog Challenge 9

    Epilog Challenge 9
  • Paper Contest 2018

    Paper Contest 2018
  • Pro Tips Challenge

    Pro Tips Challenge

We have a be nice policy.
Please be positive and constructive.




I did it and added multiple output (2,3,4,5,6)

The only problem I have is that the outputs blinks when it'S ON (HIGH). Is there a way to solve the problem?

Never mind! Turns out I had flashing LEDs.... With standards LED it works great!


Iam new to arduino ,i tried executing the same code but iam not getting the gui page and the blink of led too.Can you please help me.I have put the screen shot of com3 too.


nice instructable.

How could I access different arduinos via my ethernet? EG five arduinos, accessible from the web via port forwarded IP through my router - or would I have to use one arduino to route appropriate traffic to relevant arduinos?

Many thanks


If you want to use an adress from "the outside of your network" you need to portforward your router. So you may ask yourself what is portforwarding? For example http servers uses port 80. In your house you have let's say 5 PCs, each with a different internal IP adress. The router needs to know where to transfer the info from port 80 because when you use the ip provided by the internet provider you contact the router not the arduino/pc. If you want to acces your arduino, you have to say the router to which computer he has to redirect that port. Something like: Internet -> router -> tell the router to send the information to arduino (portforward)->arduino. I never used a ethernet shield on my arduino and never dealt with ethernet on arduino, but I think that is your problem.

Hello everyone,

I am a beginner with Arduino, actually, I want to use an ethernet shield with Arduino. but there is one question my mind.

Can the ethernet shield attached with Arduino be used as OUTPUT to collect the data from sensors or always it only works as an INPUT for the internet connection?

Thank you in advance for your precious time.


I am having Arduino Uno board with me. Which ethernet shield is compatible with Arduino Uno?



good tutorial, i found it very useful, however i was wondering could you write me a code example, so it could control 9 LED's?

Thank you.

I want to know does i need to make server or webpage additionaly for controlling my led or i can access my led through this program only over the internet