I had the Duemilanove and Ethernet shield together in front of me, and tried some examples from Arduino web site and IDE. Ethernet client seems to work and DHCP, but the server does not. That is a pity, because that would interest me most
The shield is an old card too, it does not have HW for the SD card. It uses a Wiznet W5100 chip. I have no extra power, just the USB, but other examples work with it, so should the shield too?
I tried but it did not work. But can you make it print it's IP address. Because I got the examples working by using Ethernet.begin(mac); But then I had to use whatever IP it got. I come here to write a new post about that.
I dont know why it works but I sure would like to know.
You should get into your router and see what ip address/subnet it is using for the localnet. Then check the dhcp server settings and see what ip addresses it will issue. You should use a static ip that is in the subnet of the router's ip, but not in the dhcp server range.
If you have a challenge with that, post the make and model of the router you are using.
That is when my local net is using http://192.168.100.16/ for the shield when it works, I should give it an address starting with 10.0.0.0 or 172.16.0.0 . I'll try that.
I tried to use 10.0.0.33 for both sketches and they did not work. Then without the IP part the example from Arduino IDE worked. The code from Arduino playground did not do anything visible either way.
By the way, is this correct?
Ethernet.begin(mac, ip, gateway, gateway, subnet);
The Gateway is there twice. This is from the playground sketch.
Below is some simple code I modified to try to match the ip address you posted. Post the code in the IDE and upload, start the serial monitor, then click on the blue http url in the code posted in the IDE.
//zoomkat 3-1-12
//simple button GET for pin and servo control
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html
//address will look like http://192.168.100.16:84 when submited
//for use with W5100 based ethernet shields
#include <SPI.h>
#include <Ethernet.h>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 100, 16 }; // ip in lan
byte gateway[] = { 192, 168, 100, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port
String readString;
//////////////////////
void setup(){
pinMode(5, OUTPUT); //pin selected to control
//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
myservo.write(90); //set initial servo position if desired
myservo.attach(7); //the pin for the servo co
//enable serial data print
Serial.begin(9600);
Serial.println("server LED test 1.0"); // so I can keep track of what is loaded
}
void loop(){
// Create a client connection
EthernetClient client = server.available();
if (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);
}
//if HTTP request has ended
if (c == '\n') {
///////////////
Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
client.println("<TITLE>Arduino GET test page</TITLE>");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1>Zoomkat's simple Arduino button</H1>");
client.println("
<input type=\"button\" value=\"ON\" onmousedown=\"location.href ('/?on');\"/>");
client.println("<input type=\"button\" value=\"OFF\" onmousedown=\"location.href ('/?off');\"/>");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
//stopping client
client.stop();
///////////////////// control arduino pin
if(readString.indexOf("on") >0)//checks for on
{
myservo.write(40);
digitalWrite(5, HIGH); // set pin 4 high
Serial.println("Led On");
}
if(readString.indexOf("off") >0)//checks for off
{
myservo.write(140);
digitalWrite(5, LOW); // set pin 4 low
Serial.println("Led Off");
}
//clearing string for next read
readString="";
}
}
}
}
}
LMI:
Which way it is. At first glance I thought it was Ethernet.begin(mac, ip, gateway, subnet); Is it really necessary to have the subnet field twice?
Actually, it is this format, but if you are not using dns, you can use the gateway ip as a "placeholder".