int status = WL\_IDLE\_STATUS; while (status != WL\_CONNECTED) { Serial.print("Connecting to "); Serial.println(ssid); status = WiFi.begin(ssid, pass); delay(5000); }
void loop() { WiFiClient client = server.available(); if (client) { String line = ""; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c);
if (c != '\n' && c != '\r') { line += c; }
if (c == '\n') { if (line.length() == 0) { 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(); client.println("<!DOCTYPE HTML>"); client.println("<html>"); client.println("test"); client.println("</html>"); break; } else { line = ""; } } } }
int status = WL\_IDLE\_STATUS; while (status != WL\_CONNECTED) { Serial.print("Connecting to "); Serial.println(ssid); status = WiFi.begin(ssid, pass); delay(5000); }
void loop() { WiFiClient client = server.available(); if (client) { String line = ""; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c);
if (c != '\n' && c != '\r') { line += c; }
if (c == '\n') { if (line.length() == 0) { 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(); client.println("<!DOCTYPE HTML>"); client.println("<html>"); client.println("test"); client.println("</html>"); break; } else { if (line.startsWith("GET /on ")){ digitalWrite(LED\_BUILTIN, HIGH); } if (line.startsWith("GET /off ")) { digitalWrite(LED\_BUILTIN, LOW); }