from machine import Pin, ADC
import time
vert_pin = ADC(Pin(26))
horz_pin = ADC(Pin(27))
sel_pin = Pin(5, Pin.IN, Pin.PULL_UP)
def read_joystick(): return vert_pin.read_u16(), horz_pin.read_u16()
while True:
vert, horz = read_joystick()
print("Vertical: ", vert, " Horizontal: ", horz)
if not sel_pin.value(): print("Joystick button pressed!")
time.sleep(0.01)