Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8609

Python • Re: Reset gpio output when test is finished

$
0
0
Recently I had the need to switch between micropython GPIO function and PWM function repeatedly .
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



Viewing all articles
Browse latest Browse all 8609

Trending Articles