I am building a 3 dof servo robot that is going to be controlled via wifi with an esp8266 (still in the post) I have a camera feed in the web page code and controls for the servos. The code below shows where I am at but my main question is how the arduino code knows what has been pressed in the website. I know it has something to do with the parameter 200 taking the spiff data. I am working on ajax code for sliders but will just get the ahref links working first for 30 degree increments.
//nCr Robotics Luke Jamie control servos and video feed over wifi
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
Servo servo1
Servo servo2
const char webui[] PROGMEM = R"=====(
Servo Control
Click to turn Servo1 30 degrees
Click to turn Servo1 60 degress
Click to turn Servo1 90 degrees
Click to turn Servo1 120 degress
Click to turn Servo1 150 degrees
Click to turn Servo1 180 degress
Click to turn Servo2 30 degrees
Click to turn Servo2 60 degress
Click to turn Servo2 90 degrees
Click to turn Servo2 120 degress
Click to turn Servo2 150 degress
Click to turn Servo2 180 degrees
Click to turn Servo3 30 degress
Click to turn Servo3 60 degress
Click to turn Servo3 90 degrees
Click to turn Servo3 120 degress
Click to turn Servo3 150 degrees
Click to turn Servo3 180 degress
Servo 1 inbetween 1-180
Servo 2 inbetween 1-180
Servo 3 inbetween 1-180
Servo State
)====="; //---------------------------------------------------------------const char* ssid = "xxx";
const char* password = "123";
ESP8266WebServer server(80); //Server on port 80
void handleRoot() {
String s = webui;
server.send(200, "text/html", s);}
void servo1_30degrees(){
servo1.write(30);
server.send(200, "text/html", "30 degrees");}
void servo1_60degrees() {
servo1.write(60);
server.send(200, "text/html", "60 degrees");}
void servo1_90degrees(){
servo1.write(90);
server.send(200, "text/html", "90 degrees");}
void servo1_120degrees(){
servo1.write(120);
server.send(200, "text/html", "120 degrees");}
void servo1_150degrees() {
servo1.write(150);
server.send(200, "text/html", "150 degrees");}
void servo1_180degrees(){
servo1.write(180);
server.send(200, "text/html", "180 degrees");}
void servo2_30degrees(){
servo2.write(30);
server.send(200, "text/html", "30 degrees");}
void servo2_60degrees() {
servo2.write(60);
server.send(200, "text/html", "60 degrees");}
void servo2_90degrees(){
servo2.write(90);
server.send(200, "text/html", "90 degrees");}
void servo2_120degrees(){
servo2.write(120);
server.send(200, "text/html", "120 degrees");}
void servo2_150degrees() {
servo2.write(150);
server.send(200, "text/html", "150 degrees");}
void servo2_180degrees(){
servo2.write(180);
server.send(200, "text/html", "180 degrees");}
void servo1_30degrees(){
servo3.write(30);
server.send(200, "text/html", "30 degrees");}
void servo1_60degrees() {
servo3.write(60);
server.send(200, "text/html", "60 degrees");}
void servo1_90degrees(){
servo3.write(90);
server.send(200, "text/html", "90 degrees");}
void servo1_120degrees(){
servo3.write(120);
server.send(200, "text/html", "120 degrees");}
void servo1_150degrees() {
servo3.write(150);
server.send(200, "text/html", "150 degrees");}
void servo1_180degrees(){
servo3.write(180);
server.send(200, "text/html", "180 degrees");}
void setup(void){
void forminput1(){
}
servo.attach(9);
Serial.begin(115200);
WiFi.begin(ssid, password); //Connect to your WiFi router
Serial.println("");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
Serial.println("HTTP server started");
}
void loop(void){
server.handleClient();
}