im getting a error like
error: 'class WiFiServer' has no member named 'arg'
my code
#define ENA 14 // Enable/speed motors Right GPIO14(D5)
#define ENB 12 // Enable/speed motors Left GPIO12(D6)
#define IN_1 13 // L298N in1 motors Rightx GPIO13(D7)
#define IN_2 15 // L298N in2 motors Right GPIO15(D8)
#define IN_3 2 // L298N in3 motors Left GPIO2(D4)
#define IN_4 0 // L298N in4 motors Left GPIO0(D3)
#include "Arduino.h"
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
String command; //String to store app command state.
int speedCar = 100; // 400 - 1023.
const char* ssid = "your wifi";
const char* password = "your password";
WiFiServer server(80);
IPAddress local_IP(192, 168, 1, 184);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);
void setup() {
pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN_1, OUTPUT);
pinMode(IN_2, OUTPUT);
pinMode(IN_3, OUTPUT);
pinMode(IN_4, OUTPUT);
Serial.begin(115200);
// Connecting WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi Connected");
server.begin();
Serial.println("Server Connected");
Serial.print("Go to this link: https://");
Serial.println(WiFi.localIP());
}
void goAhead(){
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar);
}
void goBack(){
digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}
void goRight(){
digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar);
}
void goLeft(){
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}
void goAheadRight(){
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar);
}
void goAheadLeft(){
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar);
}
void goBackRight(){
digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}
void goBackLeft(){
digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}
void stopRobot(){
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}
void loop() {
WiFiClient client = server.available();
if (!client) {
return;
}
Serial.println("Waiting for new client");
while (!client.available()) {
delay(1);
}
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
if (request.indexOf("/State=F")) command = "F";
else if (request.indexOf("/State=B")) command = "B";
else if (request.indexOf("/State=L")) command = "L";
else if (request.indexOf("/State=R")) command = "R";
else if (request.indexOf("/State=I")) command = "I";
else if (request.indexOf("/State=G")) command = "G";
else if (request.indexOf("/State=J")) command = "J";
else if (request.indexOf("/State=H")) command = "H";
else if (request.indexOf("/State=0")) command = "0";
else if (request.indexOf("/State=1")) command = "1";
else if (request.indexOf("/State=2")) command = "2";
else if (request.indexOf("/State=3")) command = "3";
else if (request.indexOf("/State=4")) command = "4";
else if (request.indexOf("/State=5")) command = "5";
else if (request.indexOf("/State=6")) command = "6";
else if (request.indexOf("/State=7")) command = "7";
else if (request.indexOf("/State=8")) command = "8";
else if (request.indexOf("/State=9")) command = "9";
else if (request.indexOf("/State=S")) command = "S";
else Serial.println("Wrong command");
command = server.arg("State");
if (command == "F") goAhead();
else if (command == "B") goBack();
else if (command == "L") goLeft();
else if (command == "R") goRight();
else if (command == "I") goAheadRight();
else if (command == "G") goAheadLeft();
else if (command == "J") goBackRight();
else if (command == "H") goBackLeft();
else if (command == "0") speedCar = 100;
else if (command == "1") speedCar = 117;
else if (command == "2") speedCar = 135;
else if (command == "3") speedCar = 153;
else if (command == "4") speedCar = 170;
else if (command == "5") speedCar = 190;
else if (command == "6") speedCar = 205;
else if (command == "7") speedCar = 223;
else if (command == "8") speedCar = 240;
else if (command == "9") speedCar = 255;
else if (command == "S") stopRobot();
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<br><a href=\"/State=G\"><button>ahead left</button></a>");
client.println("<a href=\"/State=F\"><button>ahead</button></a>");
client.println("<a href=\"/State=I\"><button>ahead right</button></a><br>");
client.println("<br><a href=\"/State=L\"><button>left</button></a>");
client.println("<a href=\"/State=S\"><button>stop</button></a>");
client.println("<a href=\"/State=R\"><button>right</button></a><br>");
client.println("<br><a href=\"/State=H\"><button>back left</button></a>");
client.println("<a href=\"/State=B\"><button>back</button></a>");
client.println("<a href=\"/State=J\"><button>back right</button></a><br>");
client.println("<a href=\"/State=0\"><button>Speed 0</button></a>");
client.println("<a href=\"/State=1\"><button>Speed 1</button></a>");
client.println("<a href=\"/State=2\"><button>Speed 2</button></a>");
client.println("<a href=\"/State=3\"><button>Speed 3</button></a>");
client.println("<a href=\"/State=4\"><button>Speed 4</button></a>");
client.println("<a href=\"/State=5\"><button>Speed 5</button></a>");
client.println("<a href=\"/State=6\"><button>Speed 6</button></a>");
client.println("<a href=\"/State=7\"><button>Speed 7</button></a>");
client.println("<a href=\"/State=8\"><button>Speed 8</button></a>");
client.println("<a href=\"/State=9\"><button>Speed 9</button></a>");
client.println("</html>");
delay(1);
Serial.println("Client disconnected");
}
actually im making a web controlled car where it can be controlled with any device.
thanks in advance.