Witam, mam 15 lat i próbuję stworzyć program do WeMos'a d1 r2, który będzie miał za zadanie sterować servomechanizmem. Za wszelką pomoc będę bardzo wdzięczny.
Weryfikuje program, i wyskakuje ten błąd: expected unqualified-id before '=' token
Korzystałem z tego żródła: https://circuits4you.com/2018/02/05/esp8266-arduino-wifi-web-server-led-on-off-control/
PROGRAM wygląda tak:
#include <Servo.h>
Servo = servo;
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
//ESP Web Server Library to host a web page
#include <ESP8266WebServer.h>
//---------------------------------------------------------------
//Our HTML webpage contents in program memory
const char MAIN_page[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<body>
<center>
<h1>WiFi LED on off demo: 1</h1><br>
Ciclk to turn <a href="servoON">servoON</a><br>
Ciclk to turn <a href="servoOFF">servoOFF</a><br>
<hr>
</center>
</body>
</html>
)=====";
//---------------------------------------------------------------
#define servo A0
const char* ssid = "NIEWIADOMO";
const char* password = "213213221";
ESP8266WebServer server(80); //Server on port 80
void handleRoot() {
Serial.println("You called root page");
server.send(200, "text/html", MAIN_page); //Send web page
}
void handleservoON() {
Serial.println("servo on page");
servo.write(180);
server.send(200, "text/html", "servo is ON"); //Send ADC value only to client ajax request
}
void handleservoOFF() {
Serial.println("servo off page");
servo.write(0);
server.send(200, "text/html", "servo is OFF"); //Send ADC value only to client ajax request
}
void setup(void){
Serial.begin(115200);
WiFi.begin(ssid, password); //Connect to your WiFi router
Serial.println("");
f
servo.write(0);
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
//If connection successful show IP address in serial monitor
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP()); //IP address assigned to your ESP
server.on("/", handleRoot); //Which routine to handle at root location. This is display page
server.on("/servoON", handleLEDon); //as Per <a href="ledOn">, Subroutine to be called
server.on("/servoOFF", handleLEDoff);
server.begin(); //Start server
Serial.println("HTTP server started");
}
void loop(void){
server.handleClient(); //Handle client requests
}
Zrobiłem parę poprawek i działa
Oto zmieniony program:
#include <Servo.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
//ESP Web Server Library to host a web page
#include <ESP8266WebServer.h>
Servo Servo1;
//---------------------------------------------------------------
//Our HTML webpage contents in program memory
const char MAIN_page[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<body>
<center>
<h1>WiFi LED on off demo: 1</h1><br>
Ciclk to turn <a href="servoON">servoON</a><br>
Ciclk to turn <a href="servoOFF">servoOFF</a><br>
<hr>
</center>
</body>
</html>
)=====";
//---------------------------------------------------------------
//On board LED Connected to GPIO2
//#define servo A0
const char* ssid = "VR600";
const char* password = "Dzieci_4";
ESP8266WebServer server(80); //Server on port 80
void handleRoot() {
Serial.println("You called root page");
server.send(200, "text/html", MAIN_page); //Send web page
}
void handleLEDon() {
Serial.println("servo on page");
Servo1.write(90);
server.send(200, "text/html", "servo is ON"); //Send ADC value only to client ajax request
}
void handleLEDoff() {
Serial.println("servo off page");
Servo1.write(0);
server.send(200, "text/html", "servo is OFF"); //Send ADC value only to client ajax request
}
//==============================================================
// SETUP
//==============================================================
void setup(void){
Serial.begin(115200);
Servo1.attach(14);
WiFi.begin(ssid, password); //Connect to your WiFi router
Serial.println("");
Servo1.write(90);
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
//If connection successful show IP address in serial monitor
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP()); //IP address assigned to your ESP
server.on("/", handleRoot); //Which routine to handle at root location. This is display page
server.on("/servoON", handleLEDon); //as Per <a href="ledOn">, Subroutine to be called
server.on("/servoOFF", handleLEDoff);
server.begin(); //Start server
Serial.println("HTTP server started");
}
//==============================================================
// LOOP
//==============================================================
void loop(void){
server.handleClient(); //Handle client requests
}