Control Multiple Servo motors using ESP32: Multiple Servo ESP-SERV3

Project Video
Project Details

This video shows how to control position of Multiple Servo Motor using ESP32 Microcontroller to move it from 0° to 180° or from 180° to 0° or set your own values. You need to download the libary specifically
work with ESP32 Arduino IDE/

We have 3 type of controling Servo Motor with ESP32

  • code ESP-SERV1 Using ESP32 to Control Servo motor to move it 0° to 180° or in reverse or any angle
  • code ESP-SERV2 Using ESP32 to Control Servo motor with Potentiometer to move it 0° to 180° or in reverse or any angle
  • code ESP-SERV3 Using ESP32 to Control Multiple Servo motors to move them 0° to 180° or in reverse or any angle

The link to use in the "preferences" of Arduino IDE for ESP32 board Watch video for instructions.

Project Code

 * Original sourse:
 * This is Arduino code to control Servo motor with ESP32 boards.
 The position of servo is controlled more thean one servo motor
 * Watch video instruction for this code:
 * Written/updated by Ahmad Shamshiri for Robojax Video channel
 * Date: Dec 17, 2019, in Ajax, Ontario, Canada
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purpose only.
 * this code has been downloaded from
 * Get this code and other Arduino codes from
Learn Arduino step by step in structured course with all material, wiring diagram and library
all in once place. Purchase My course on

Get early access to my videos via Patreon and have  your name mentioned at end of very 
videos I publish on YouTube here: (watch until end of this video to list of my Patrons)

or make donation using PayPal

 *  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been download from
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see .

const int servoCount = 4;// how many servo 
static const int servosPins[servoCount] = {12, 14, 27, 26}; // define pins here

Servo_ESP32 servos[servoCount];//do not change

* this funciton is to move all servos to the same angle. Watch video for instruction
void setServos(int degrees) {
    for(int i = 0; i < servoCount; ++i) {
        servos[i].write((degrees + (35 * i)) % 180);

void setup() {
	Serial.print("Robojax ESP32 Multiple servo");

    for(int i = 0; i < servoCount; ++i) {
        if(!servos[i].attach(servosPins[i])) {
            Serial.print("Servo ");
            Serial.println("attach error");

void loop() {
	// multiple Servo using ESP32
    for(int posDegrees = 0; posDegrees <= 180; posDegrees++) {

    for(int posDegrees = 180; posDegrees >= 0; posDegrees--) {

If you found this Arduino course helpful, please support me so I can continue creating content like this. support me via PayPal