Loading Servo Lab...
A servo motor is a small, compact device used to rotate parts of a machine with high precision.
Unlike a standard motor that just spins round and round like a fan, a servo is designed to go to a specific angle and hold that position. If you tell a servo to move to 90 degrees, it moves there and fights to stay there.

Before we start coding, it's crucial to understand where Servos fit in the world of motors.
Not all servos are the same. Switch tabs below to see the difference between the two main types.
A standard servo uses a potentiometer attached to the output shaft. This acts as a feedback sensor.
Tell the servo exactly where to go. It handles the rest.
1#include <Servo.h>
2
3Servo myServo;
4
5void setup() {
6 myServo.attach(D2);
7}
8
9void loop() {
10 myServo.write(0); // Go to 0 degrees
11 delay(1000);
12
13 myServo.write(90); // Go to 90 degrees (Middle)
14 delay(1000);
15
16 myServo.write(180); // Go to 180 degrees
17 delay(1000);
18}This wiring applies to both types of servos.