In the beginning, Maybe 1 out of 3 times my Ethernet connected.
I’m using a 5100.
NOW, it does not connect at all.
The example code with the Arduino does not help.
My project, a web page that shows the sonar readings of my robot, etc.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte gateway[] = { 192, 168, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };
EthernetServer server(80);//server port
String readString;
...
void setup()
{
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
Ethernet.begin(mac, ip, gateway, subnet);
//Ethernet.begin(mac, ip);
server.begin();
Serial.print("ROBOTEEP Internal Server is at ");
Serial.println(Ethernet.localIP()); //<--This code appears to do nothing
EthernetControl();
}
void EthernetControl()
{
//First Create a client connection
EthernetClient client = server.available();
if (client) //<--THE PROBLEM - NO CLIENT IS AVAILABLE
{
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 .ROBOTEEP Network Connect"); //send new page
client.println("Content-Type: text/html");
client.println();
//client.println("Refresh: 5");//refresh every five seconds OR
//client.println("<meta http-equiv=\"refresh\" content=\"5\">");//refresh every five seconds
client.println("<HTML>");
client.println("<HEAD>");
MORE CODE FOR APPEARANCE
}//END OF if (c == '\n') (if HTTP request has ended)
}//END OF if (client.available())
}//END OF while (client.connected())
}//END OF if (client)
EthernetControl();
}
Moderator edit: Please, please someone tell me why it is so hard to understand the importance of using code tags?