Ethernet Help: Simple?

Guys I wrote a very simple program (just got the shield :)) and the webpage is not displaying? I was thinking it may be an issue with the default IP gateway? Mine is 192.168.0.1, whilst I think the default is 192.168.1.1. Anyway, its not a problem with the HTML coding as the page does not respond. I tried the basic example one (the one provided with the IDE) and nothing.

Here is my current code:

#include <SPI.h>
#include <Ethernet.h>

int led=8;

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {192, 168, 5, 177};
EthernetServer server(80);
String readString;

void setup(){
  Serial.begin(9600);
  pinMode(led,OUTPUT);
  Ethernet.begin(mac, ip);
  Serial.print("Server is Up");
}

void loop(){
  EthernetClient client = Serial.available();
  if(client){
    while(client = client.connected()){
      if(client = client.available()){
        char c = client.read();
        
        readString += c;
        Serial.print(c);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<h1>");
client.println("<TITLE>client's LED Control</TITLE>");
client.println("</h1>");
client.println("<BODY bgcolor='green'>");
client.println("
");
client.println("<a href=\"/?lighton\"\">client ON</a>");
client.println("<a href=\"/?lightoff\"\">client OFF<a>");   
client.println("</BODY>");
client.println("</HTML>");

if(readString.indexOf("?lighton" > 0)) digitalWrite(led,HIGH);
if(readString.indexOf("?lightoff" > 0)) digitalWrite(led,LOW);

delay(10);
      }
    }
  }
}

Mine is 192.168.0.1, whilst I think the default is 192.168.1.1.

Log into your router and see what it is for sure.

zoomkat:
Log into your router and see what it is for sure.

The access to my router is 192.168.0.1 so should I set my gateway to 192.168.0.1?

The access to my router is 192.168.0.1 so should I set my gateway to 192.168.0.1?

If that is the case, you should change this.

// change this
byte ip[] = {192, 168, 5, 177};
// to this
byte ip[] = {192, 168, 0, 177};

That will change the gateway for you and the assigned ip should be accessible from the localnet computers.

Just read the serial monitor. Server is at: 0.0.0.0. Not looking to good.

If the IP is set static by your sketch, and it is showing 0.0.0.0, then you have a problem with the SPI bus or the SPI side of the w5100. It is a w5100 ethernet controller, not a enc28j60?

If your ethernet shield is a w5100 type, you can try the below client test code unmodified to see if you get a response from the server.

//zoomkat 3-1-13
//simple client checkip test
//for use with IDE 1.0.1 or later
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "checkip.dyndns.com"; // test web page server
EthernetClient client;

//////////////////////

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600); 
  Serial.println("Better client ip test 3/1/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET / HTTP/1.0"); //download text
    client.println("Host: checkip.dyndns.com");
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor 
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}

zoomkat:
If your ethernet shield is a w5100 type, you can try the below client test code unmodified to see if you get a response from the server.

//zoomkat 3-1-13

//simple client checkip test
//for use with IDE 1.0.1 or later
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "checkip.dyndns.com"; // test web page server
EthernetClient client;

//////////////////////

void setup(){

if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

Serial.begin(9600);
  Serial.println("Better client ip test 3/1/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  } 
}

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET / HTTP/1.0"); //download text
    client.println("Host: checkip.dyndns.com");
    client.println(); //end of get request
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor
  }

Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}

It is a W5100, but the code returns nothing in the serial monitor. I mean nothing literally. I just checked the board and the chip is running hot, normal? Also I see a few pins are joined together through a solder bridge?

Make sure the shield pins are in the correct holes as they are easy to miss align.
Also, if you don't see anything in the serial monitor, maybe your baud rate is incorrect or other setup issue.

zoomkat:
Make sure the shield pins are in the correct holes as they are easy to miss align.
Also, if you don't see anything in the serial monitor, maybe your baud rate is incorrect or other setup issue.

Misalign? Are only the SPI pins needed for the ethernet shield to work? If so I have a connector I can use, and see what the problem actually is.

Are only the SPI pins needed for the ethernet shield to work?

Pins 4, 10, 11, 12, 13, power, and ground (for a Uno) need to be connected.

Pins 50 to 53, the appropriate chip select pin for the SD card, power and ground are needed for the Mega.

Note that the code I posted requires that an SD card NOT be inserted in the SD slot. If you have an SD card inserted, remove it and try the code.