Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By Kamillx
#87819 hello I created this code please help, I mean after pressing the button on the website for 2 seconds the switch turns on and then automatically turns off

Code: Select all               Serial.println("GPIO 5 off");
              btState = "off";
             digitalWrite(bt, LOW);
            }
           
            // Display the HTML web page
            client.println("<!DOCTYPE html><html>");
            client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
            client.println("<link rel=\"icon\" href=\"data:,\">");
            // CSS to style the on/off buttons
            // Feel free to change the background-color and font-size attributes to fit your preferences
            client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
            client.println(".button { background-color: #195B6A; border: none; color: white; padding: 16px 40px;");
            client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");
            client.println(".button2 {background-color: #77878A;}</style></head>");
           
            // Web Page Heading
            client.println("<body><h1>ESP8266 Web Server</h1>");
           
            // Display current state, and ON/OFF buttons for GPIO 5 
            client.println("<p>GPIO 5 - State " + btState + "</p>");
            // If the output5State is off, it displays the ON button       
            if (btState=="off") {
              client.println("<p><a href=\"/brama/on\"><button class=\"button\">ON</button></a></p>");
            } else {
              client.println("<p><a href=\"/brama/off\"><button class=\"button button2\">OFF</button></a></p>");
            }
            client.println("</body></html>");
           
            // The HTTP response ends with another blank line
            client.println();
            // Break out of the while loop
            break;
          } else { // if you got a newline, then clear currentLine
            currentLine = "";
          }
       } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }
      }
    }
    // Clear the header variable
    header = "";
    // Close the connection
    client.stop();
    Serial.println("Client disconnected.");
    Serial.println("");
  }y
}