keyestudio WiKi
client.println("HTTP/1.1 200
indicate that the server successfully processed the request
client.println("Content-Type:
HTML
client.println("Connection:
response is finished
client.println();
response header and to begin the body content
client.println(webPage);
the client, so that the client will receive a message containing "Hello World!" as
response
}
// base control
void baseControl(int
int
angleVal
=
map(angle, 0, 180, 180, 0);
0
Serial.println(angleVal);
if
(angleVal
>
baseAngle) {
greater than the servo Angle (the value of the slider is 0-180)
while
(angleVal
servo Angle, use while function: servo plus one degree every 10ms till the servo
equals the slider value
base.write(baseAngle++);
adds one
if
(baseAngle
delay(10);
}
else if
}
(angleVal
smaller than the servo Angle
while
(angleVal
servo Angle, use while function: servo minus one degree every 10ms till the
Angle equals the slider value
base.write(baseAngle--);
decreases one
if
(baseAngle
delay(10);
}
}
}
//The logic of baseControl function can also be applied to the following three functions.
What difference is the Angle mapping. Because of their structures, some
rotation range can not reach 0-180, so the range is adjusted.
// upper arm control
void armControl(int
int
angleVal
=
map(angle, 0, 180, 80, 180);
if
(angleVal
>
armAngle) {
while
(angleVal
arm.write(armAngle++);
if
(armAngle
>=
delay(10);
156
OK");
text/html");
close");
angle) {
>
baseAngle) {
>=
180) baseAngle
=
<
baseAngle) {
<
baseAngle) {
<=
0) baseAngle
=
0;
angle) {
>
armAngle) {
180) armAngle
=
180;
//Sends an HTTP response header
//Set the type of the response content
//Disconnect to the client when
//Send a blank line to end the
//Send the defined HTML page content
//map function: map values in 0-180 to 180-
//Whether the value of the page slider
//If the slider value is greater than
//set servo angle:
180;
//set the maximum of baseAngle
//delay 10ms
//Whether the value of the page slider
//If the slider value is smaller than
//set servo angle:
//set the minimum of baseAngle
Chapter 9. 9. Robot Arm Projects
(continued from previous page)
to␣
the␣
HTTP␣
"baseAngle++"baseAngle␣
the␣
servo␣
"baseAngle--"baseAngle␣
servo␣
(continues on next page)
to␣
to␣
a␣
is␣
the␣
Angle␣
is␣
Need help?
Do you have a question about the ESP32 and is the answer not in the manual?
Questions and answers