from machine import  Pin, ADC
import utime

x_axis = ADC(Pin(2, Pin.IN))
y_axis = ADC(Pin(4, Pin.IN))

def print_joystick_direction(x, y):
    if (x > 2000 and x < 2096 and y > 2000 and y < 2096):
        print("Position: MIDDLE")
    elif (x > 2096):
        print("Position: LEFT")
    elif (x < 2000):
        print("Position: RIGHT") 
    if (y > 2096):
        print("Position: UP")
    elif (y < 2000):
        print("Position: DOWN")
    
while True:
    x_val = x_axis.read()
    y_val = y_axis.read()
        
    print("X value:", x_val)
    print("Y value:", y_val)

    print_joystick_direction(x_val, y_val);
    
    print("")

    utime.sleep(0.5)