I have a question.
I followed the step by step of the book and managed to successfully create the proposed application in ESP32 with firebase. My question is how do I replace the PWM LEDs to be controlled by a servo motor, I don’t have much experience with ESP and I still can’t identify where in the code I should make the change and add the servo.write() function. If you have an example with a servomotor that I can observe and that is not connected through a webserver but through firebase with the sliders of the application.
Thank you very much.
We don’t have any examples for Firebase and servo motors.
First, remove all sections that refer to the PWM LEDs.
Then, include the servo library and create a servo object on your desired pin as shown in the first example in this tutorial: https://randomnerdtutorials.com/esp32-servo-motor-web-server-arduino-ide/
Then, instead of having something as shown below for LEDs:
int pwmValue = result.to<int>();
ledcWrite(slider1Channel, map(pwmValue, 0, 100, 0, 255));
You’ll add the corresponding command to control a servo.
int post = result.to<int>();
myservo.write(pos); // tell servo to go to position in variable 'pos'
Try it out, and then tell me if you need further help.
I tell you, when I put to work independently the servomotor works well, but when I activate the lines of the ledcSetup library the servomotor stops responding, if I decomment those lines the servo works fine. Since I need that the slider two works with a led and the slider 1 is the one that is going to work with the servomotor.