Il mio problema è questo: quando accendo il led dal sito, il led si accende. Quando però spengo il led dalla seriale, il led si spegne, ma al refresh automatico, dato che sull'url rimane la richiesta html "?L1=1", il led si riaccende. Come posso risolevere il problema
Questa è solo una parte di programma dato che quello totale è da più di 800
void controlloLuci() { //Controllo luci dal sito
if (luce1)
{
digitalWrite(LSOGG, HIGH);
statoLSOGG = true;
accHtml=false;
luce1 = NULL;
}
if (!luce1) {
digitalWrite(LSOGG, LOW);
statoLSOGG = false;
speHtml=false;
luce1 = NULL;
}
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
boolean currentLineIsBlank = true;
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' && currentLineIsBlank) {
//CREA LA PAGINA HTML (VERRA' AGGIORNATA AD OGNI ISTRUZIONE NUOVA)
Serial.print("2");
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 10"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println(F("<html><head> <title> Casa Domotica </title> <meta charset=UTF-8/></head><body style=background-color:powderblue;>"));
client.println(F("<h1 align=center style=color:red>Casa Domotica</h1> "));
client.println(F("<div align=center valign=middle>"));
client.println(F("<table>"));
client.println(F("<tr>"));
client.println(F("<td >Luce Soggiorno</td>"));
client.println(F("<td><a href='?L1=1' name=L1 value=1><button> Accendi </button></a></td> "));
if (statoLSOGG) {
client.println(F("<td style=background-color:lime;>            </td>"));
}
else {
client.println(F("<td style=background-color:red;>            </td>"));
}
client.println(F("<td><a href='?L1=0' name=L1 value=0><button> Spegni </button></a></td>"));
client.println(F("</tr>"));
client.println(F("</table>"));
client.println(F("</div>"));
//CHIUDE I TAG HTML PER LA PAGINA
client.println(F("</body></html>"));
if (readString.indexOf("L1=1") > 0)
{
luce1 = true;
}
else if (readString.indexOf("L1=0") > 0)
{
luce1 = false;
}
controlloLuci();
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
//SI PREPARA PER UNA NUOVA ISTRUZIONE
readString = "";
delay(1);
//TERMINA LE OPERAZIONI CLIENTE
client.stop();
}