How to access ethernet shield from multiple devices

Hi,

I'm new to Arduino (more familiar with Basic Stamp) and I'm trying to utilize the Ethernet Shield along with the Arduino UNO I'm connected to. I'm trying to access access the shield from multiple computers but seem to have a problem. I can run my ethernet shield only on the computer it's connected to but when I type in the IP address on any other computer or try to ping my shield from a different device it does not connect. Below is a simple code to turn an LED On/Off through a browser. Please help me figure out a way to access this LED from a different computer.

/*
Web Server
A simple web server
Circuit:

  • 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, 0x0F, 0x28, 0x6F };

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

IPAddress ip = IPAddress(169,254,234,76);
//IPAddress gateway(10,0,0,4);
//IPAddress subnet(255, 255, 0, 0);

// Initialize the Ethernet server library with the port you want to use.
EthernetServer server(80);
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
Serial.begin(9600);

//start Ethernet
Ethernet.begin(mac, ip);
//Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
Serial.print("Server is at ");
Serial.println(Ethernet.localIP());
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;
//Serial.print(c);

Serial.write(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");
client.println();
client.println("");
client.println("");

//--------------------------------------------------------------------------------------------------------
//-------------------------------------------------

// what is being Displayed :

client.println("Michael & Erin, MECH 208, Ethernet Shield");
client.println("");
client.println("");
client.println("");
client.println("

Michael & Erin, MECH 208, Ethernet Shield

");
client.println("
");
client.println("");

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

client.println("");
client.println("");

delay(1);
//stopping client
client.stop();

//-------------------------------------------------
// 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");
}
else{
if(readString.indexOf("?lightoff") >0)//checks for off
{
digitalWrite(8, LOW); // set pin 8 low
Serial.println("Led Off");
}
}
//clearing string for next read
readString="";

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

}
}
}
}
}
}

This is probably the reason. Is it connected directly to your computer?

PAddress ip = IPAddress(169,254,234,76);

If so, you need to connect it to a router instead. It is easier to route that than if connected to your computer's ethernet port.

Thanks for the info. I connected my ethernet shield to my home router and found the IP address to be 10.0.0.10 so I used the code below but now when I enter this IP into my browser nothing comes up. Even if I do get this to work through my router, will I be able to access the shield through a computer that's outside my home router? Basically I'm trying to see if I can connect the shield to my router and have a global address so I can access it from anywhere.

" IPAddress ip = IPAddress(10,0,0,10); "

I would start by putting more serial.prints in the arduino program. Are you monitoring the arduino serial data while you are trying to access the arduino from the browser?

If your arduino prog appears to be working but nothing happens when you put the IP address into your browser then I would suspect that the IP address or port, etc. is not right.

Basically I'm trying to see if I can connect the shield to my router and have a global address so I can access it from anywhere.

That part is fairly simple. Use a dynamic IP service like no-ip.com to get the outside request to your router, and then do port forwarding on the router to your arduino.