Servo motor (sg90) simply doesnot works with ESP32. But works with Arduino.

kadovpk
Posts: 2
Joined: Thu Oct 21, 2021 1:56 am

Servo motor (sg90) simply doesnot works with ESP32. But works with Arduino.

Postby kadovpk » Thu Oct 21, 2021 2:05 am

Hello, there. I'm new here and a lover of ESP32. However, I really tried to not create this topic but I just dont know what to do.

The title of this topic explained everything. I did put a servo motor connect to an arduino and it work. When I try with ESP32, this servo just does not move. I've tried some gpio and external font. (Yes, I linked the ground).

Could someone help me? Thanks a lot.

ESP_Sprite
Posts: 9040
Joined: Thu Nov 26, 2015 4:08 am

Re: Servo motor (sg90) simply doesnot works with ESP32. But works with Arduino.

Postby ESP_Sprite » Thu Oct 21, 2021 8:28 am

Would help if you could post your hardware setup and code...

kadovpk
Posts: 2
Joined: Thu Oct 21, 2021 1:56 am

Re: Servo motor (sg90) simply doesnot works with ESP32. But works with Arduino.

Postby kadovpk » Thu Oct 21, 2021 11:08 am

The code and hardware setup are not a big deal because of basic test, but here they are:

Arduino Code:

Code: Select all

// Include the Servo library 
#include <Servo.h> 
// Declare the Servo pin 
int servoPin = 3; 
// Create a servo object 
Servo Servo1; 
void setup() { 
   // We need to attach the servo to the used pin number 
   Servo1.attach(servoPin); 
}
void loop(){ 
   // Make servo go to 0 degrees 
   Servo1.write(0); 
   delay(1000); 
   // Make servo go to 90 degrees 
   Servo1.write(90); 
   delay(1000); 
   // Make servo go to 180 degrees 
   Servo1.write(180); 
   delay(1000); 
}
Arduino Hardware:
ESP32 Code:

Code: Select all

#include <ESP32Servo.h>
 
Servo myservo;  // create servo object to control a servo
int servoPin = 13;
int pos = 0;    // variable to store the servo position

void setup() {
	myservo.attach(servoPin); // attaches the servo on pin 13 to the servo object
}
 
void loop() {
   // Make servo go to 0 degrees 
   myservo.write(0); 
   delay(1000); 
   // Make servo go to 90 degrees 
   myservo.write(90); 
   delay(1000); 
   // Make servo go to 180 degrees 
   myservo.write(180); 
   delay(1000);
}
ESP32 Hardware:

Who is online

Users browsing this forum: No registered users and 68 guests