void handleADC(){
int a = analogRead(A0);
a = map(a,0,1023,0,100);
String adc = String(a);
Serial.println(adc);
server.send(200, "text/plane",adc); //sends data to server
}
void handleRoot(){
server.sendHeader("Location", "/index.html",true); //Redirect to our html web page
server.send(302, "text/plane","");
}
//Initialize File System
SPIFFS.begin();
Serial.println("File System Initialized");
Serial.print("Setting AP (Access Point)…");
Serial.println();
//Connect to wifi Network
WiFi.mode(WIFI_AP); //Only Access point
WiFi.softAP(ssid, password); //Start HOTspot
//If connection successful show IP address in serial monitor
Serial.print("Connected to: ");
Serial.println(ssid);
IPAddress IP = WiFi.softAPIP();
Serial.print("Server IP address: ");
Serial.println(IP);
//Initialize Webserver
server.on("/",handleRoot);
server.on("/getADC",handleADC); //Reads ADC function is called from out index.html
server.onNotFound(handleWebRequests); //Set setver all paths are not found so we can handle as per URI
server.begin();
Serial.println("HTTP server started");
}