how do i know which code is best to set pwm frequency.
First you have to define "best"
Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project.
I find using the ESP32's API to be much better for PWM than using the available ESP32 servo library. The ESP32 servo library has an issue in how it assigns the hardware timers. Most people won't encounter the issue so the author does not fix it. The ESP32 servo library uses the LEDC API, I much prefer using the MCPWM API.
Thus, for me, the best PWM thingy is the ESP32's MCPWM API. Motor Control Pulse Width Modulator (MCPWM) - ESP32 - — ESP-IDF Programming Guide latest documentation (espressif.com), works under the Arduino IDE.
Try it and see.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.