from machine import Pin,PWM
from utime import sleep
button = Pin(18, Pin.IN)
speed = 1023  #Speed range:0~1023
def motor(L12,L13,R14,R15):
    PWM(Pin(12)).duty(L12) 
    PWM(Pin(13)).duty(L13) 
    PWM(Pin(14)).duty(R14) 
    PWM(Pin(15)).duty(R15)
if __name__ == "__main__":
    while button.value() == 1:
        pass
    else:
        while True:
           motor(0,speed,0,speed)
           sleep(0.5)
           motor(speed,0,speed,0)
           sleep(0.5)
           motor(speed,0,0,speed)
           sleep(0.5)
           motor(0,speed,speed,0)
           sleep(0.5)
        


