from machine import PWM,Pin
import time
S1=PWM(Pin(18),freq=50,duty=128)
S2=PWM(Pin(27),freq=50,duty=128)
def rotate (servo,degree):
servo.duty(int (degree* 0.54 + 25.6))
while 1:
for i in range(0,181,1):
rotate(S1,i)
rotate(S2,180-i)
time.sleep_us(10)
for i in range(180,-1,-1):
rotate(S1,i)
rotate(S2,180-i)
time.sleep_us(10)