Hello,
I'm using sparkfun ProEthernet , and I have connect to him a sensor.
in my code the page change only when I press F5 (refresh) , and so I can see the change on my sensor
what to I need to do /change in order that it will change automatically?
let say every 1 second?
I want to see "live" as possible
this is my code
void loop()
{
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == '\n' && currentLineIsBlank) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();client.print("Sensor Status (input 4)");
if (digitalRead(sensor) ==HIGH)
{
digitalWrite(RedLED, LOW);
digitalWrite(GreenLED,HIGH);
client.print("water on");
client.println("
");
}
else
{
client.print("water off");
client.println("
");
digitalWrite(GreenLED,LOW);
digitalWrite(RedLED,HIGH);
delay(5000);}
break;
}
if (c == '\n') {
currentLineIsBlank = true;
}
else if (c != '\r') {
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
}
}
Thank you!