from machine import Pin, PWM
import time
in1=Pin(18,Pin.OUT)
in2=Pin(5,Pin.OUT)
in3=Pin(16,Pin.OUT)
in4=Pin(4,Pin.OUT)
enA=PWM(Pin(21))
enB=PWM(Pin(2))
enA.freq(1000)
enB.freq(1000)
while True:
# motor 1 forward direction
in1.on()
in4.on()
enA.duty(1023)
time.sleep(1)
# motor 1 reverse direction
in1.off()
in4.off()
enA.duty(1)
time.sleep(1)
# motor 2 forward direction
in2.on()
in3.on()
enB.duty(1023)
time.sleep(1)
# motor 2 reverse direction
in2.off()
in3.off()
enB.duty(1)
time.sleep(1)