GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — webctrl/webctrl.ino at master · YUZHENFEI/webctrl

Expand file tree

/

webctrl.ino

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
160 lines (146 loc) · 3.43 KB
/

webctrl.ino

Copy path

File metadata and controls

160 lines (146 loc) · 3.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include <Servo.h>
HardwareSerial & esp8266 = Serial2;
#define DEBUG true
#define sg92r_pin 9
#define sg92_pin 10
Servo sg92r,sg92;
int current_position = 0;
int current_position1 = 90;
int vel = 10;
int minimum_position = 0;
int maximum_position = 180;
int medium_position = 90;
void setup()
{
sg92r.attach(sg92r_pin);
sg92r.detach();
sg92.attach(sg92_pin);
sg92.detach();
Serial.begin(115200);
esp8266.begin(115200);
esp8266Data("AT+RST\r\n", 2000, DEBUG); //reset module
esp8266Data("AT+CWMODE=1\r\n", 1000, DEBUG); //set station mode
esp8266Data("AT+CWJAP=\"AIFORU-828\",\"aiforu2017\"\r\n", 2000, DEBUG); //connect wifi network
while(!esp8266.find("OK")) { //wait for connection
}
esp8266Data("AT+CIFSR\r\n", 1000, DEBUG);
esp8266Data("AT+CIPMUX=1\r\n", 1000, DEBUG);
esp8266Data("AT+CIPSERVER=1,80\r\n", 1000, DEBUG);
}
void loop()
{
if (esp8266.available())
{
if (esp8266.find("+IPD,"))
{
String msg;
esp8266.find("?");
msg = esp8266.readStringUntil(' ');
String command = msg.substring(0, 3); // intercept first 3 chars
String valueStr = msg.substring(4); //intercept from the 5th char
int value = valueStr.toInt();
if (DEBUG) {
Serial.println(command);
Serial.println(value);
}
delay(100);
//move servo1 to desired angle in vertical direction
if(command == "sr1") {
//limit input angle
if (value >= maximum_position) {
value = maximum_position;
}
if (value <= minimum_position) {
value = minimum_position;
}
sg92r.attach(sg92r_pin); //attach servo
while(current_position != value) {
if (current_position > value) {
current_position -= 1;
sg92r.write(current_position);
delay(100/vel);
}
if (current_position < value) {
current_position += 1;
sg92r.write(current_position);
delay(100/vel);
}
}
sg92r.detach(); //dettach
}
//move servo1 to desired angle in horizontal direction
if(command == "sr2") {
//limit input angle
if (value >= maximum_position) {
value = maximum_position;
}
if (value <= minimum_position) {
value = minimum_position;
}
sg92.attach(sg92_pin); //attach servo
while(current_position1 != value) {
if (current_position1 > value) {
current_position1 -= 1;
sg92.write(current_position1);
delay(100/vel);
}
if (current_position1 < value) {
current_position1 += 1;
sg92.write(current_position1);
delay(100/vel);
}
}
sg92.detach(); //dettach
}
if (command == "res") {
sg92r.attach(sg92r_pin);
while(current_position != minimum_position) {
if (current_position > minimum_position) {
current_position -= 1;
sg92r.write(current_position);
delay(100/vel);
}
if (current_position < minimum_position) {
current_position += 1;
sg92r.write(current_position);
delay(100/vel);
}
}
sg92r.detach(); //dettach
sg92.attach(sg92_pin); //attach servo
while(current_position1 != medium_position) {
if (current_position1 > medium_position) {
current_position1 -= 1;
sg92.write(current_position1);
delay(100/vel);
}
if (current_position1 < medium_position) {
current_position1 += 1;
sg92.write(current_position1);
delay(100/vel);
}
}
sg92.detach(); //dettach
}
}
}
}
String esp8266Data(String command, const int timeout, boolean debug)
{
String response = "";
esp8266.print(command);
long int time = millis();
while ( (time + timeout) > millis())
{
while (esp8266.available())
{
char c = esp8266.read();
response += c;
}
}
if (debug)
{
Serial.print(response);
}
return response;
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.