/* * ESP8266 NodeMCU LED - Buzzer Control over WiFi (AP Mode) * * https://circuits4you.com */ #include #include //ESP Web Server Library to host a web page #include // SSID parameters const char *ssid = "ESP8266_AP_Mode_Arac"; const char *password = "12345678"; IPAddress ip(192, 168, 4, 1); // IP Address IPAddress netmask(255, 255, 255, 0); // Netmask //Declare a global object variable from the ESP8266WebServer class. ESP8266WebServer server(80); //Server on port 80 //--------------------------------------------------------------- //Our HTML webpage contents in program memory const char MAIN_page[] PROGMEM = R"=====( Wifi Araç Kontrol Paneli

Wifi Araç Kontrolü Esp8266 AP Mode V2



   
   

Bas-Çek Butonlar

   
   

)====="; //--------------------------------------------------------------- //On board LED Connected to GPIO2 #define sagLedPin D8 #define solLedPin D7 #define buzzerPin D0 #define PWMA D3 #define PWMB D4 #define inA1 D5 #define inA2 D6 #define inB1 D1 #define inB2 D2 //=============================================================== // This routine is executed when you open its IP in browser //=============================================================== void handleRoot() { Serial.println("You called root page"); String s = FPSTR(MAIN_page); //Read HTML contents server.send(200, "text/html", s); //Send web page } void handleVites1() { Serial.println("Vites 1"); analogWrite(PWMA,700); analogWrite(PWMB,700); server.send(200, "text/html", "Vites 1"); //Send ADC value only to client ajax request } void handleVites2() { Serial.println("Vites 2"); analogWrite(PWMA,850); analogWrite(PWMB,850); server.send(200, "text/html", "Vites 2"); //Send ADC value only to client ajax request } void handleVites3() { Serial.println("Vites 3"); analogWrite(PWMA,1023); analogWrite(PWMB,1023); server.send(200, "text/html", "Vites 3"); //Send ADC value only to client ajax request } void handleFarAc() { Serial.println("Far Acik"); digitalWrite(sagLedPin,HIGH); digitalWrite(solLedPin,HIGH); server.send(200, "text/html", "Far Açık"); //Send ADC value only to client ajax request } void handleFarKapat() { Serial.println("Far Kapali"); digitalWrite(sagLedPin,LOW); digitalWrite(solLedPin,LOW); server.send(200, "text/html", "Far Kapalı"); //Send ADC value only to client ajax request } void handleKornaAc() { Serial.println("Korna Acik"); digitalWrite(buzzerPin,HIGH); server.send(200, "text/html", "Korna Açık"); //Send ADC value only to client ajax request } void handleKornaKapat() { Serial.println("Korna Kapali"); digitalWrite(buzzerPin,LOW); server.send(200, "text/html", "Korna Kapalı"); //Send ADC value only to client ajax request } void handleSol() { Serial.println("Sol"); digitalWrite(inA1,HIGH); digitalWrite(inA2,LOW); digitalWrite(inB1,LOW); digitalWrite(inB2,HIGH); server.send(200, "text/html", "Sol"); //Send ADC value only to client ajax request } void handleSag() { Serial.println("Sag"); digitalWrite(inA1,LOW); digitalWrite(inA2,HIGH); digitalWrite(inB1,HIGH); digitalWrite(inB2,LOW); server.send(200, "text/html", "Sag"); //Send ADC value only to client ajax request } void handleIleri() { Serial.println("Ileri"); digitalWrite(inA1,HIGH); digitalWrite(inA2,LOW); digitalWrite(inB1,HIGH); digitalWrite(inB2,LOW); server.send(200, "text/html", "Ileri"); //Send ADC value only to client ajax request } void handleGeri() { Serial.println("Geri"); digitalWrite(inA1,LOW); digitalWrite(inA2,HIGH); digitalWrite(inB1,LOW); digitalWrite(inB2,HIGH); server.send(200, "text/html", "Geri"); //Send ADC value only to client ajax request } void handleDur() { Serial.println("Dur"); digitalWrite(inA1,LOW); digitalWrite(inA2,LOW); digitalWrite(inB1,LOW); digitalWrite(inB2,LOW); server.send(200, "text/html", "Dur"); //Send ADC value only to client ajax request } void handleSolSinyal() { Serial.println("Sol sinyal"); digitalWrite(solLedPin,HIGH); server.send(200, "text/html", "Sol sinyal"); //Send ADC value only to client ajax request } void handleSagSinyal() { Serial.println("Sag sinyal"); digitalWrite(sagLedPin,HIGH); server.send(200, "text/html", "Sag sinyal"); //Send ADC value only to client ajax request } //============================================================== // SETUP //============================================================== void setup(void){ //Tanımlı pinler output pinMode(solLedPin,OUTPUT); pinMode(sagLedPin,OUTPUT); pinMode(buzzerPin,OUTPUT); pinMode(PWMA,OUTPUT); pinMode(PWMB,OUTPUT); pinMode(inA1,OUTPUT); pinMode(inA2,OUTPUT); pinMode(inB1,OUTPUT); pinMode(inB2,OUTPUT); //Motorları Durdur digitalWrite(solLedPin,LOW); digitalWrite(sagLedPin,LOW); digitalWrite(buzzerPin,LOW); digitalWrite(inA1,LOW); digitalWrite(inA2,LOW); digitalWrite(inB1,LOW); digitalWrite(inB2,LOW); analogWrite(PWMA,700); analogWrite(PWMB,700); Serial.begin(115200); // Setup AP WiFi.mode(WIFI_AP); //Only Access point WiFi.softAPConfig(ip, ip, netmask); WiFi.softAP(ssid, password); // Get and print IP Address IPAddress myIP = WiFi.softAPIP(); Serial.print("AP IP address: "); Serial.println(myIP); server.on("/", handleRoot); //Which routine to handle at root location. This is display page server.on("/vites1", handleVites1); server.on("/vites2", handleVites2); server.on("/vites3", handleVites3); server.on("/ileri", handleIleri); server.on("/geri", handleGeri); server.on("/sol", handleSol); server.on("/sag", handleSag); server.on("/dur", handleDur); server.on("/solSinyal", handleSolSinyal); server.on("/sagSinyal", handleSagSinyal); server.on("/farAcik", handleFarAc); server.on("/farKapali", handleFarKapat); server.on("/kornaAcik", handleKornaAc); server.on("/kornaKapali", handleKornaKapat); server.begin(); //Start server Serial.println("HTTP server started"); } //============================================================== // LOOP //============================================================== void loop(void){ server.handleClient(); //Handle client requests }