Created
November 23, 2026 14:40
-
-
Save sixhat/dbfdff84fc28abea58bd4c6ebef2b4bf to your computer and use it in GitHub Desktop.
Controling two sg90 servos with ESP32 boards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Exemplo de correr dois servos ao mesmo tempo numa ESP32 | |
| */ | |
| #include <ESP32Servo.h> | |
| Servo s2; | |
| Servo s3; | |
| int it; | |
| void setup() | |
| { | |
| Serial.begin(9600); | |
| ESP32PWM::allocateTimer(0); | |
| ESP32PWM::allocateTimer(1); | |
| ESP32PWM::allocateTimer(2); | |
| ESP32PWM::allocateTimer(3); | |
| s2.setPeriodHertz(50); | |
| s3.setPeriodHertz(50); | |
| s2.attach(D2, 500, 2400); | |
| s3.attach(D3, 500, 2400); | |
| it = 0; | |
| } | |
| void loop() | |
| { | |
| s2.write(90); | |
| s3.write(90); | |
| delay(1000); | |
| s2.write(10); | |
| s3.write(10); | |
| delay(1000); | |
| s2.write(90); | |
| s3.write(90); | |
| delay(1000); | |
| s2.write(170); | |
| s3.write(170); | |
| delay(1000); | |
| Serial.println(it++); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment