from machine import Pin, ADC, PWM
import utime
# Joystick
xAxis = ADC(Pin(27))
yAxis = ADC(Pin(26))
button = Pin(16, Pin.IN, Pin.PULL_UP)
# Servo
servo = PWM(Pin(15))
servo.freq(50)
while True:
# Joystick
xValue = xAxis.read_u16()
yValue = yAxis.read_u16()
buttonValue = button.value()
print(str(xValue) + ", " + str(yValue) + ", " + str(buttonValue))
# Servo
servo.duty_u16(int(round((xValue/10)+1499, 1)))
utime.sleep(0.02)