I tried to program the car control using web on esp8266, this error came up 'class AsyncWebServer' has no member named 'arg'
//ESP
// Import required libraries
#include <Arduino.h>
#ifdef ESP32
#include <WiFi.h>
#include <AsyncTCP.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#endif
#include <ESPAsyncWebServer.h>
#include <FS.h>
/* Put your SSID & Password */
const char* ssid = "Car"; // Enter SSID here
const char* password = "12345678"; //Enter Password here
/* Put IP Address details */
IPAddress local_ip(192,168,1,1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
// Create AsyncWebServer object on port 80
AsyncWebServer server(80);
//int in1 = D5;
//int in2 = D6;
//int motor_speed = 0;
void handleJSData(){
boolean yDir;
int x = server.arg(0).toInt() * 10;
int y = server.arg(1).toInt() * 10;
int aSpeed = abs(y);
int bSpeed = abs(y);
//set the direction based on y being negative or positive
if ( y < 0 ){
yDir = 0;
}
else {
yDir = 1;
}
//adjust to speed of each each motor depending on the x-axis
//it slows down one motor and speeds up the other proportionately
//based on the amount of turning
aSpeed = constrain(aSpeed + x/2, 0, 1023);
bSpeed = constrain(bSpeed - x/2, 0, 1023);
//use the speed and direction values to turn the motors
//if either motor is going in reverse from what is expected,
//just change the 2 digitalWrite lines for both motors:
//!ydir would become ydir, and ydir would become !ydir
//MotorA
Serial.print(0);
Serial.print(1);
Serial.print(4);
//MotorB
Serial.print(2);
Serial.print(3);
Serial.print(5);
//return an HTTP 200
server.send(200, "text/plain", "");
}
void setup(){
// Serial port for debugging purposes
Serial.begin(9600);
Serial.println();
if(SPIFFS.begin()==true) {
Serial.println("SPIFFS initialised OK");
}
//pinMode(in1, OUTPUT);
//pinMode(in2, OUTPUT);
WiFi.softAP(ssid, password);
WiFi.softAPConfig(local_ip, gateway, subnet);
delay(100);
// Route for root / web page
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/index.html", "text/html");
});
server.on("/assets/css/foundation.css", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/assets/css/foundation.css", "text/css");
});
server.on("/assets/js/vendor.js", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/assets/js/vendor.js", "text/js");
});
server.on("/assets/js/foundation.js", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/assets/js/foundation.js", "text/js");
});
server.serveStatic("/assets/js/virtualjoystick.js", SPIFFS, "/assets/js/virtualjoystick.js");
//call handleJSData function when this URL is accessed by the js in the html file
server.on("/jsData.html", handleJSData);
// Start server
server.begin();
}
void loop(){
}

