pinpong pwm class

PWM Class

Constructor

Creates and initializes a PWM (Pulse Width Modulation) to output PWM signals.

pwm0 = PWM(board, Pin(board, Pin.D6))

Methods

pwm0.freq()
freq(), When called with no arguments, it returns the frequency.
f = pwm0.freq()  # Get the PWM frequency
pwm0.freq(x)
freq(x), When called with an argument, it sets the PWM frequency to x.
pwm0.freq(1000)  # Set the PWM frequency to 1000
pwm0.duty()
duty(), When called with no arguments, it returns the duty cycle.
f = pwm0.duty()  # Get the PWM duty cycle
pwm0.duty(x)
duty(x), When called with an argument, it sets the PWM duty cycle, the range is 0-255.
pwm0.duty(127)  # Set the PWM duty cycle to 50%
pwm0.deinit()