支持MCPWM功能的Micropython版本
[复制链接]
ESP32分支中,目前只提供了基本的PWM功能,没有充分发挥硬件的特性。有网友增加了MCPWM功能,这对于电机驱动会有比较大的帮助。
from machine import Pin
from esp32 import MCPWM
pwm0 = PWM(0) # Create MCPWM object with timer ID (0..5)
pwm0.bind(Pin(5)) # Bind to output Pin
pwm0.freq(500) # Set frequency in Hz
pwm0.freq() # Get achieved frequency
pwm0.duty(20) # Set duty in percent
pwm0.duty() # Get achieved duty
pwm0.start() # Start/resume output
pwm0.stop() # Stop output
|