#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168,1, 120 };
EthernetServer server(80);
float latitude=13.08;
float longitude=80.20;
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac, ip);
server.begin();
}
void loop()
{
Ethernet_Control();
}
void Ethernet_Control()
{
EthernetClient client = server.available();
// detect if current is the first line
boolean current_line_is_first = true;
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == '\n' && current_line_is_blank) {
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: text/html"));
client.println();
client.println(F("<META HTTP-EQUIV=REFRESH CONTENT=5 URL=>"));
client.println(F("<center><p><h5>Web application V1.0</h5></p><center><hr>
"));
client.print(F("<p><h5>DATE: = <font color=indigo>"));
client.print(" <font> <color=blue> latitude: <input type=text name=01 value=");
client.println(latitude);
client.print(" <font> <color=black> Longitude: <input type=text name=01 value=");
client.println(longitude);
client.println("</form>");
client.println("</body>");
client.println("</html>");
client.println("<p>NOTE: This page will automatically refresh every 5 seconds.</p></center>");
break;
}
if (c == '\n') {
// we're starting a new line
current_line_is_first = false;
current_line_is_blank = true;
}
else if (c != '\r') {
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}