Código de Pesquisa

Controlling Multiple Servo Motors Using an ESP32: Multiple Servo ESP-SERV3

Controlling Multiple Servo Motors Using an ESP32: Multiple Servo ESP-SERV3

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/ The link to use in the "preferences" of Arduino IDE for ESP32 board https://dl.espressif.com/dl/package_esp32_index.json Watch video for instructions.
277-Code ESP-SERV2 controlling a servo motor using a potentiometer
Idioma: C++
++
/*
 * Original source: https://github.com/RoboticsBrno/ESP32-Arduino-Servo-Library
 * 
 * This is Arduino code to control servo motors with ESP32 boards.
 The position of the servo is controlled; more than one servo motor can be controlled.
 * Watch video instructions for this code: https://youtu.be/KUqR3ZLX5Ks
   
 * Written/updated by Ahmad Shamshiri for Robojax Video channel www.Robojax.com
 * 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 purposes only.
 * This code has been downloaded from https://robojax.com
 
 * Get this code and other Arduino codes from Robojax.com.
 Learn Arduino step by step in a structured course with all materials, wiring diagrams, and libraries
 all in one place. 

****************************
Get early access to my videos via Patreon and have your name mentioned at the end of every 
video I publish on YouTube here: http://robojax.com/L/?id=63 (watch until the end of this video for a list of my Patrons)
****************************

or make a donation using PayPal http://robojax.com/L/?id=64

 *  * 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 downloaded from Robojax.com
    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
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    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 <https://www.gnu.org/licenses/>.
 */
#include <Servo_ESP32.h>

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

Servo_ESP32 servos[servoCount];//do not change

/*
* This function is to move all servos to the same angle. Watch the video for instructions https://youtu.be/KUqR3ZLX5Ks
*/
void setServos(int degrees) {
    for(int i = 0; i < servoCount; ++i) {
        servos[i].write((degrees + (35 * i)) % 180);
    }
}

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

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

void loop() {
	//Robojax.com multiple servos using ESP32
    for(int posDegrees = 0; posDegrees <= 180; posDegrees++) {
        setServos(posDegrees);
        Serial.println(posDegrees);
        delay(20);
    }


    for(int posDegrees = 180; posDegrees >= 0; posDegrees--) {
        setServos(posDegrees);
        Serial.println(posDegrees);
        delay(20);
    }
}

Recursos e referências

Ainda não há recursos.

Arquivos📁

Nenhum arquivo disponível.