? Webserver - Get data back from a range slider to control a servo motor ?

Hi everyone, I´m new to programming and I´m looking for a way to control servo motors over an AP-station web server. I´d like to use a range slider to get different positions and I have already embedded the html code. But how can I get the data back from the html page?

Best regards,

Gunnar

Have you looked at the Ethernet examples in the IDE ?

I should have specified it. I´d like to use a WiFi web server with an ESP8266.

I have already embedded the html code.

In what? A glass jar that you buried in the back yard?

I just wanted to say that I'm using one file and not another file for the html code. Is there an easy way to receive the data from the web server for 2 or 3 servo motors?

Is there an easy way to receive the data from the web server for 2 or 3 servo motors?

For me, yes. You might not find it so easy.

Where is your code? After all, you are supposed to post your code when posting in the Programming section.

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <Servo.h> 


Servo servo1;  
Servo servo2;

const char* ssid = "ESP170115";

WiFiServer server(80);

String readString; 
//////////////////////

void setup(){

  Serial.begin(115200);
  delay(10);
  servo1.attach(5);  
  servo2.attach(4);
  
  //server.begin();

  servo1.write(90);
  servo2.write(63);

  Serial.println("Connected...");
  WiFi.softAP(ssid);

  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  server.begin();
  Serial.println("HTTP server started");
}

void loop()
{

  WiFiClient client = server.available();
  
  if (client) {
    Serial.println("new client");
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        
        readString += c;
      
          Serial.println(readString);

          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Servo Webserver</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H1>Servo Webserver</H1>");
        
          client.println("<form method=get>");
          client.println("<input type='range' name=slider1 min='0' max='127' value=posS1 onchange='showValue1(this.value)'>");
          client.println("<span id='range1'>0</span>"); 
          client.println("<script type='text/javascript'>\r\nfunction showValue1(newValue)\r\n{\r\ndocument.getElementById('range1').innerHTML=newValue;\r\n}\r\n</script>\r\n");
          client.println("<script type=!text/javascript!></script\r\n>");
          client.println("</form>");
          
          client.println("</BODY>");
          client.println("</HTML>");

          delay(10);

          //clearing string for next read
          readString="";

          client.stop();

       // }
      }
    }
  }
}

I really don´t have any idea how I can receive the data.

Thanks for your help.

What is in readString when the user moves the slider? That is, does moving the slider cause a GET request to be made? If not, you'll need to add a button to the form that will generate the GET request when clicked.

Is it possible to use the slider without a button that I will get the position of the slider automatically?

gb262624: Is it possible to use the slider without a button that I will get the position of the slider automatically?

You have the Arduino right there in front of you. Print the value of readString. If nothing prints when you move the slider, then the answer is no. If something prints, the answer is yes.

I found some code I can use for my task and I found a solution without a submit button: