I am trying the run an example code but i am having hard time with it.
When i try to connect to the server via browser it does not connect.
I connected the lan cable directly to my laptop. No router in between. Is that a problem?
Please help me out...
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x48, 0xC2, 0xA1, 0xF3, 0x8D, 0xB7 };
byte ip[] = { 192,168,0, 104 };
EthernetServer server(80);
void setup()
{
// Begin ethernet and server
Ethernet.begin(mac, ip);
server.begin();
}
void loop()
{
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean BlankLine = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// If line is blank and end of line is newline character '\n' = end of HTTP request
if (c == '\n' && BlankLine) {
client.println("HTTP/1.1 200 OK"); // Standard HTTP response
client.println("Content-Type: text/html\n");
client.println("<html><head><META HTTP-EQUIV=""refresh""CONTENT=""5"">\n");
client.println("<title>Arduino Web Server</title></head>");
client.println("<body>\n");
client.println("<h1>Arduino Web Server</h1>");
client.println("<h3>Internal Temperature</h3>");
client.println("Temp C:");
client.println("
");
client.println("Temp F:");
client.println("
");
client.println("<h3>External Temperature</h3>");
client.println("Temp C:");
client.println("
");
client.println("Temp F:");
client.println("
");
break;
}
if (c == '\n') {
// Starting a new line
BlankLine = true;
}
else if (c != '\r') {
// Current line has a character in it
BlankLine = false;
}
}
}
// Allow time for the browser to receive data
delay(10);
// Close connection
client.stop();
}
}