Hello, i am making a simple rc car that will be controlled over a web server but i am running into an issue where the server responds very slowly or stops responding at all after i press a few buttons. I tried sever solutions but the issue persists. Can someone help me with this issue please. Thanks in advance, Simon.
#include <ESP8266WiFi.h>
char* ssid = "";
char* password = "";
WiFiServer server(80);
void setup() {
Serial.begin(115200);
Serial.println("Hello");
Serial.print("Wifi connecting to ");
Serial.println( ssid );
WiFi.begin(ssid,password);
Serial.println();
Serial.print("Connecting");
while( WiFi.status() != WL_CONNECTED ){
delay(500);
Serial.print(F("."));
}
server.begin();
Serial.print(WiFi.localIP());
}
void loop() {
WiFiClient client = server.available();
if (!client) {
return;
}
while(!client.available()){
delay(1);
}
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: text/html\r\n"));
client.println(F("")); // do not forget this one
client.println(F("<!DOCTYPE HTML>"));
client.println(F("<html>"));
client.println(F("<meta name= \"HandheldFriendly\" content=\"True\">"));
client.println(F("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=yes\">"));
client.println(F("<body>"));
client.println(F("<br><br>"));
client.println(F("<div style=\"text-align: center; width: 50vh; height: 50vh;\">"));
client.println(F("<a href=\"/Dir=F\"\"><button style=\"width:25%; height:25%;\" >Forward</button></a>"));
client.println(F("<br>"));
client.println(F("<a href=\"/Dir=L\"\"><button style=\"width:25%; height:25%;\">Left</button></a>"));
client.println(F("<a href=\"/Dir=S\"\"><button style=\"width:25%; height:25%;\">Stop</button></a>"));
client.println(F("<a href=\"/Dir=R\"\"><button style=\"width:25%; height:25%;\">Right</button></a>"));
client.println(F("<br>"));
client.println(F("<a href=\"/Dir=B\"\"><button style=\"width:25%; height:25%\">Back</button></a><br />"));
client.println(F("</html>"));
delay(1);
Serial.println(F("Client disonnected"));
}