xfgjxdfy
srjd
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char head[] PROGMEM = R"=====(
<!DOCTYPE html>
<html lang="ru-ru">
<head>
<meta charset="utf-8">
<style>
h1, button {
text-align:center;
font-size:48pt;
font-weight:bold;
}
</style>
</head><body>
)=====";
const char top[] PROGMEM = R"=====(
<h1>Hello, Ваня и Максим!</h1>
)=====";
const char center1[] PROGMEM = R"=====(
<p1><button onclick="window.location.replace('/led_on');">Включить</button></p1>
)=====";
const char center2[] PROGMEM = R"=====(
<p1><button onclick="window.location.replace('/led_off');">Выключить</button></p1>
)=====";
const char foot[] PROGMEM = R"=====(
</body></html>
)=====";
String ssid = "Машинка ";
String password = "12345678";
ESP8266WebServer server(80);
IPAddress ip(192, 168, 1, 1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
void setup() {
WiFi.softAPConfig(ip, gateway, subnet);
ssid += String(WiFi.macAddress()).substring(12);
WiFi.softAP(ssid, password); // password не обязательно
server.on("/", indexhtml);
server.on("/led_on", led_on);
server.on("/led_off", led_off);
server.begin();
}
void loop() {
server.handleClient();
delay(5);
}
void indexhtml(){
String html_page = String(head) + String(top) + String(center1) + String(foot);
server.send(200, "text/html", html_page);
}
void led_off() {
indexhtml();
}
void led_on() {
String html_page = String(head) + String(top) + String(center2) + String(foot);
server.send(200, "text/html", html_page);
}
xfyjk
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char head[] PROGMEM = R"=====(
<!DOCTYPE html>
<html lang="ru-ru">
<head>
<meta charset="utf-8">
<style>
h1, button {
text-align:center;
font-size:48pt;
font-weight:bold;
}
</style>
</head><body>
)=====";
const char top[] PROGMEM = R"=====(
<h1>Hello, Ваня и Максим!</h1>
)=====";
const char center1[] PROGMEM = R"=====(
<p1><button onclick="window.location.replace('/led_on');">Включить</button></p1>
)=====";
const char center2[] PROGMEM = R"=====(
<p1><button onclick="window.location.replace('/led_off');">Выключить</button></p1>
)=====";
const char foot[] PROGMEM = R"=====(
<a href="/set?x=15&y=Hello">THJRNJDYMTTYDNJ</a>
</body></html>
)=====";
String ssid = "Машинка ";
String password = "12345678";
ESP8266WebServer server(80);
IPAddress ip(192, 168, 1, 1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
void setup() {
Serial.begin(115200);
WiFi.softAPConfig(ip, gateway, subnet);
ssid += String(WiFi.macAddress()).substring(12);
WiFi.softAP(ssid, password); // password не обязательно
server.on("/", indexhtml);
server.on("/led_on", led_on);
server.on("/led_off", led_off);
server.onNotFound(not_found_or_set);
server.begin();
}
void loop() {
server.handleClient();
delay(5);
}
void not_found_or_set() {
int x = server.arg("x").toInt();
String y = server.arg("y");
Serial.println(x);
Serial.println(y);
String html_page = String(head) + String(top) + String(center2) + String(foot);
server.send(200, "text/html", html_page);
}
void indexhtml(){
String html_page = String(head) + String(top) + String(center1) + String(foot);
server.send(200, "text/html", html_page);
}
void led_off() {
indexhtml();
}
void led_on() {
String html_page = String(head) + String(top) + String(center2) + String(foot);
server.send(200, "text/html", html_page);
}
xfjfy
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char head[] PROGMEM = R"=====(
<!DOCTYPE html>
<html lang="ru-ru">
<head>
<meta charset="utf-8">
<style>
h1, button, form, input, p {
text-align:center;
font-size:48pt;
font-weight:bold;
}
</style>
</head><body>
)=====";
const char top[] PROGMEM = R"=====(
<h1>Hello, Ваня и Максим!</h1>
)=====";
const char center1[] PROGMEM = R"=====(
<p><button onclick="window.location.replace('/led_on');">Включить</button></p>
)=====";
const char center2[] PROGMEM = R"=====(
<p><button onclick="window.location.replace('/led_off');">Выключить</button></p>
)=====";
const char center3[] PROGMEM = R"=====(
<form method=get action="/dialog">
<p><INPUT type=text name=text>
<p><INPUT type=submit>
</form>
)=====";
const char foot[] PROGMEM = R"=====(
</body></html>
)=====";
String ssid = "Машинка ";
String password = "12345678";
ESP8266WebServer server(80);
IPAddress ip(192, 168, 1, 1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
void setup() {
Serial.begin(115200);
WiFi.softAPConfig(ip, gateway, subnet);
ssid += String(WiFi.macAddress()).substring(12);
WiFi.softAP(ssid, password); // password не обязательно
server.on("/", indexhtml);
server.on("/led_on", led_on);
server.on("/led_off", led_off);
server.onNotFound(not_found_or_set);
server.begin();
}
void loop() {
server.handleClient();
delay(5);
}
void not_found_or_set() {
String y = server.arg("text");
Serial.println(y);
String html_page = String(head) + String(top) + String(center2) + String(center3) + String(foot);
server.send(200, "text/html", html_page);
}
void indexhtml(){
String html_page = String(head) + String(top) + String(center1) + String(center3) + String(foot);
server.send(200, "text/html", html_page);
}
void led_off() {
indexhtml();
}
void led_on() {
String html_page = String(head) + String(top) + String(center2) + String(center3) + String(foot);
server.send(200, "text/html", html_page);
}
dfhd
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char head[] PROGMEM = R"=====(
<!DOCTYPE html>
<html lang="ru-ru">
<head>
<meta charset="utf-8">
<style>
h1, button, form, input, p {
text-align:center;
font-size:48pt;
font-weight:bold;
}
</style>
</head><body>
)=====";
const char top[] PROGMEM = R"=====(
<h1>Hello, Ваня и Максим!</h1>
)=====";
const char center1[] PROGMEM = R"=====(
<p><button onclick="window.location.replace('/led_on');">Включить</button></p>
)=====";
const char center2[] PROGMEM = R"=====(
<p><button onclick="window.location.replace('/led_off');">Выключить</button></p>
)=====";
const char center3[] PROGMEM = R"=====(
<form method=get action="/dialog">
<p><INPUT type=text name=text>
<p><INPUT type=submit>
</form>
)=====";
const char foot[] PROGMEM = R"=====(
</body></html>
)=====";
String ssid = "Машинка ";
String password = "12345678";
ESP8266WebServer server(80);
IPAddress ip(192, 168, 1, 1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
String history;
void setup() {
Serial.begin(115200);
WiFi.softAPConfig(ip, gateway, subnet);
ssid += String(WiFi.macAddress()).substring(12);
WiFi.softAP(ssid, password); // password не обязательно
server.on("/", indexhtml);
server.on("/led_on", led_on);
server.on("/led_off", led_off);
server.onNotFound(not_found_or_set);
server.begin();
}
void loop() {
server.handleClient();
delay(5);
}
void not_found_or_set() {
String y = server.arg("text");
Serial.println(y);
history = "<p>" + y + "</p>" + history;
String html_page = String(head) + String(top) + String(center2) + String(center3)+ history + String(foot);
server.send(200, "text/html", html_page);
}
void indexhtml(){
String html_page = String(head) + String(top) + String(center1) + String(center3) + String(foot);
server.send(200, "text/html", html_page);
}
void led_off() {
indexhtml();
}
void led_on() {
String html_page = String(head) + String(top) + String(center2) + String(center3) + String(foot);
server.send(200, "text/html", html_page);
}
Лист. 1. Чат
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <Servo.h>
const char head[] PROGMEM = R"=====(
<!DOCTYPE html>
<html lang="ru-ru">
<head>
<meta charset="utf-8">
<style>
h1, button, form, input, p {
text-align:center;
font-size:48pt;
font-weight:bold;
}
</style>
</head><body>
)=====";
const char top[] PROGMEM = R"=====(
<h1>Hello, Ваня и Максим!</h1>
)=====";
const char center1[] PROGMEM = R"=====(
<p><button onclick="window.location.replace('/led_on');">Включить</button></p>
)=====";
const char center2[] PROGMEM = R"=====(
<p><button onclick="window.location.replace('/led_off');">Выключить</button></p>
)=====";
const char center3[] PROGMEM = R"=====(
<form method=get action="/dialog">
<p><INPUT type=text name=text>
<p><INPUT type=submit>
</form>
)=====";
const char foot[] PROGMEM = R"=====(
</body></html>
)=====";
String ssid = "KAMAZ ";
String password = "12345678";
ESP8266WebServer server(80);
IPAddress ip(192, 168, 1, 1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
String history;
Servo servo;
const int servoPin = 12;
void setup() {
Serial.begin(115200);
servo.attach(servoPin);
servo.write(90);
WiFi.softAPConfig(ip, gateway, subnet);
ssid += String(WiFi.macAddress()).substring(12);
WiFi.softAP(ssid, password); // password не обязательно
server.on("/", indexhtml);
server.on("/led_on", led_on);
server.on("/led_off", led_off);
server.onNotFound(not_found_or_set);
server.begin();
}
void loop() {
server.handleClient();
delay(5);
}
void not_found_or_set() {
String y = server.arg("text");
if(y.toInt()!=0){
servo.write(y.toInt());
}
history = "<p>" + y + "</p>" + history;
String html_page = String(head) + String(top) + String(center2) + String(center3)+ history + String(foot);
server.send(200, "text/html", html_page);
}
void indexhtml(){
String html_page = String(head) + String(top) + String(center1) + String(center3) + String(foot);
server.send(200, "text/html", html_page);
}
void led_off() {
indexhtml();
}
void led_on() {
String html_page = String(head) + String(top) + String(center2) + String(center3) + String(foot);
server.send(200, "text/html", html_page);
}
Лист. 2. Управление серовоприводом
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <Servo.h>
const char head[] PROGMEM = R"=====(
<!DOCTYPE html>
<html lang="ru-ru">
<head>
<meta charset="utf-8">
<style>
h1, button, form, input, p {
text-align:center;
font-size:48pt;
font-weight:bold;
}
</style>
</head><body>
)=====";
const char top[] PROGMEM = R"=====(
<h1>Hello, Ваня и Максим!</h1>
)=====";
const char center1[] PROGMEM = R"=====(
<p><button onclick="window.location.replace('/led_on');">Левая</button></p>
)=====";
const char center2[] PROGMEM = R"=====(
<p><button onclick="window.location.replace('/led_off');">Правая</button></p>
)=====";
const char center3[] PROGMEM = R"=====(
<form method=get action="/dialog">
<p><INPUT type=text name=text>
<p><INPUT type=submit>
</form>
)=====";
const char foot[] PROGMEM = R"=====(
</body></html>
)=====";
String ssid = "KAMAZ ";
String password = "12345678";
ESP8266WebServer server(80);
IPAddress ip(192, 168, 1, 1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
String history;
Servo servo;
const int servoPin = 12;
const int ledLeft = 14;
const int ledRight = 16;
void setup() {
pinMode(ledLeft, OUTPUT);
pinMode(ledRight, OUTPUT);
Serial.begin(115200);
servo.attach(servoPin);
servo.write(90);
WiFi.softAPConfig(ip, gateway, subnet);
ssid += String(WiFi.macAddress()).substring(12);
WiFi.softAP(ssid, password); // password не обязательно
server.on("/", indexhtml);
server.on("/led_on", led_on);
server.on("/led_off", led_off);
server.onNotFound(not_found_or_set);
server.begin();
}
void loop() {
server.handleClient();
delay(5);
}
void not_found_or_set() {
String y = server.arg("text");
if(y.toInt()!=0){
servo.write(y.toInt());
}
if(y.toInt()>90){
digitalWrite(ledLeft, 1);
digitalWrite(ledRight, 0);
}
if(y.toInt()<90 and y.toInt()!=0){
digitalWrite(ledRight, 1);
digitalWrite(ledLeft, 0);
}
if(y.toInt()==90){
digitalWrite(ledRight, 0);
digitalWrite(ledLeft, 0);
}
history = "<p>" + y + "</p>" + history;
String html_page = String(head) + String(top) + String(center2) + String(center3)+ history + String(foot);
server.send(200, "text/html", html_page);
}
void indexhtml(){
String html_page = String(head) + String(top) + String(center1) + String(center3) + String(foot);
server.send(200, "text/html", html_page);
}
void led_off() {
indexhtml();
}
void led_on() {
String html_page = String(head) + String(top) + String(center2) + String(center3) + String(foot);
server.send(200, "text/html", html_page);
}
Лист. 3. Управление светодиодами.