from machine import Pin,PWM,ADC   
from utime import sleep
left=ADC(Pin(35,Pin.PULL_DOWN))
right=ADC(Pin(34,Pin.PULL_DOWN))
button = Pin(18,Pin.IN)
speed = 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:
            ADC_L=left.read()
            ADC_R=right.read()
            print("ADC_L:",ADC_L)
            print("ADC_R:",ADC_R)
            sleep(0.2)
            if ADC_L - ADC_R > 800:
                motor(0,speed,speed,0)
                
            elif ADC_R - ADC_L > 800:
                motor(speed,0,0,speed)
                
            elif ADC_R < 2800 and ADC_L <2800:
                motor(0,speed,0,speed)
                
            else:
                motor(0,0,0,0)
