Index
Introduction
Servo motors are precise actuators that rotate to specific angles between 0° and 180°.
With the PWM (Pulse Width Modulation) capability of the ESP32-S3 DevKit-N16R8, you can easily control the servo’s position.
This is ideal for robotics and automated systems where accurate angular movement is required.
Required Components
- ESP32-S3 Board
- Servo Motor
- Jumper wires
- Breadboard
- 5V Power Supply, Battery
Pinout

Circuit Diagram / Wiring
- SERVO (5V) → ESP32 5V an external 5V power supply
- SERVO (GND) → ESP32 GND
- SERVO (Signal) → ESP32 GPIO 13

Code / Programming
/*
Filename: ol_servo_sweep.ino
Description: ESP32-S3 code to control a servo motor by sweeping it to 0°, 90°, and 180° positions with 1-second delay.
Author: www.oceanlabz.in
Modification: 1/4/2025
*/
#include <Servo.h> // Include Servo library
Servo myServo; // Create Servo object
void setup() {
myServo.attach(13); // Attach the servo to GPIO 13 (safe pin for PWM on ESP32-S3)
}
void loop() {
myServo.write(0); // Move to 0°
delay(1000); // Wait for 1 second
myServo.write(90); // Move to 90°
delay(1000); // Wait for 1 second
myServo.write(180); // Move to 180°
delay(1000); // Wait for 1 second
}
Explanation
Servo.h
library simplifies PWM-based servo control.attach(13)
connects the servo signal to GPIO 13 (PWM-capable on ESP32-S3).write(angle)
rotates the servo to the specified angle (0°–180°).
Troubleshooting
- If the servo jitters or doesn’t move, check if the external 5V power supply is stable.
- Ensure GPIO 13 supports PWM (ESP32-S3 supports PWM on most GPIOs).
- Always connect GND of the servo and ESP32-S3 DevKit-N16R8 together.