Using Servo Motors (SG90)

Servo motors give you precise control over their movements. Ideal for moving arms or joints in your DIY project. In this video, I’ll explain how to use the SG90 (a great cheap servo motor) with the ESP32. No additional hardware required!

Useful resources

Wiring diagram:

How to connect the SG90 How to connect the SG90

Full code used in this video:

#include <Arduino.h>
#include <ESP32Servo.h> 

#define PIN_SERVO 13
Servo myServo;

void setup(){
  myServo.attach(PIN_SERVO);
}

void loop(){
  for (int pos = 0; pos <= 180; pos += 20) {
    myServo.write(pos);
    delay(500);
  }

  myServo.write(0);
  delay(1000);
}