esp-idf/examples/peripherals/mcpwm/mcpwm_servo_control
Angus Gratton 66fb5a29bb Whitespace: Automated whitespace fixes (large commit)
Apply the pre-commit hook whitespace fixes to all files in the repo.

(Line endings, blank lines at end of file, trailing whitespace)
2020-11-11 07:36:35 +00:00
..
main Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00
CMakeLists.txt build_app: make multi target support readable 2020-04-09 16:40:57 +08:00
Makefile Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00
README.md build_app: make multi target support readable 2020-04-09 16:40:57 +08:00

Supported Targets ESP32

MCPWM servo motor control Example

This example will show you how to use MCPWM module to control servo motor

Assign pulse width range and the maximum degree, accordingly the servo will move from 0 to maximum degree continuously

Step 1: Pin assignment

  • GPIO18 is assigned as the MCPWM signal for servo motor

Step 2: Connection

  • connect GPIO18 with servo pwm signal
  • other two wires of servo motor are VCC and GND

Step 3: Initialize MCPWM

  • You need to set the frequency(generally 50 Hz) and duty cycle of MCPWM timer
  • You need to set the MCPWM channel you want to use, and bind the channel with one of the timers