keyestudio WiKi
/*
Keyestudio ESP32 Robot Arm
8-8 Servo Configuration
Function: Set servo at pin IO2 to the angle of 90°
http://www.keyestudio.com
*/
#include
<ESP32Servo.h>
// create a servo objects Customizable name
Servo servo;
int
servoPin
=
2;
//Connect servo to pin IO2
void
setup()
{
servo.attach(servoPin);
servo.write(0);
//Set servo angle to 0°
delay(1000);
servo.write(180);
delay(1000);
servo.write(90);
}
void
loop() {
}
After uploading the code, the servo will initialize to 0° first. Then it rotates from 0 to 180° and then it maintains at 90°.
We need to ensure the servo is at 90° position before installing.
76
//Set servo angle to 180°
//Set servo angle to 90°
Chapter 8. 8. Assembly
Need help?
Do you have a question about the ESP32 and is the answer not in the manual?
Questions and answers