import time from pyb import Pin, Timer tim = Timer(4, freq=1000) # Frequency in Hz ch1 = tim.channel(1, Timer.PWM, pin=Pin("P7"), pulse_width_percent=0) while (True): x = 50 ch1.pulse_width_percent(x)