PWM signal to one pin instead of all
-
So Im trying to understand if all the pins are directly connected to a single PWM? In my case I'm using a WiPy, when I run my code all my pins seem to get that signal as I have multiple servos moving, however im specifying a single pin to get the PWM signal.
Im only calling one function at a time.
import machine import time def shelfServoOpenA(): pwm = machine.PWM(0, frequency=50) pwm_ca = pwm.channel(0, pin='P23', duty_cycle=0.02) time.sleep(2) print("A Going to 60") pwm_ca.duty_cycle(0.2450) def shelfServoCloseA(): pwm = machine.PWM(0, frequency=50) pwm_ca = pwm.channel(0, pin='P23', duty_cycle=0.02) time.sleep(2) print("A Going to 0") pwm_ca.duty_cycle(0.0450) def shelfServoOpenB(): pwm = machine.PWM(0, frequency=50) pwm_cb = pwm.channel(0, pin='P22', duty_cycle=0.02) time.sleep(2) print("B Going to 60") pwm_cb.duty_cycle(0.2450) def shelfServoCloseB(): pwm = machine.PWM(0, frequency=50) pwm_cb = pwm.channel(0, pin='P22', duty_cycle=0.02) time.sleep(2) print("B Going to 0") pwm_cb.duty_cycle(0.0450)
-
@Dezert754 you probably want to use different timers (the first argument to
machine.PWM
) and/or different channels (the first argument topwm.channel
). Probably the latter rather the former.You can also probably avoid instantiating / configuring each time you need to do something.