Recently I had the need to switch between micropython GPIO function and PWM function repeatedly .
Found this working (snippet):
Found this working (snippet):
Code:
pin = machine.Pin(16, machine.Pin.OUT)pwm = machine.PWM(pin, freq=234, duty_u16=10000)# initialize PWMpwm = machine.PWM(pin, freq=int(freq), duty_u16=int(duty))... set duty cycle as needed# deinitialize PWMpwm.deinit()pin = machine.Pin(16, machine.Pin.OUT)... set values as neededpin.value(0)Statistics: Posted by ghp — Thu Mar 13, 2025 11:05 am