from machine import Pin, PWM # I import the PIN library and the PWM library
import time # I import time
servo = PWM(Pin(15)) # Configure pin 15 as a PWM signal output.
servo.freq(50) # Set the frequency to 50
for i in range(2000, 6000, 100): # Create a sweep from 2000 to 6000 in steps of 100.
servo.duty_u16(i) # Update the servo position with each cycle increment.
time.sleep(0.05) # Brief pause of 50 ms to generate a smooth and non-jerky movement.