import machine
import time

pin = machine.Pin(17)
pwm = machine.PWM(pin)
pwm.freq(50)

joy = machine.ADC(26)

min = 1000
max = 7200

difference = 6200
degrees = difference /180

while True:
  print("ADC0")
  print(joy.read_u16())
  time.sleep(1)

  if joy.read_u16() < 500:
    angle = 135
    duty = min + int (angle * degrees)
    pwm.duty_u16(duty)

  elif joy.read_u16() > 63000:
    angle =45
    duty = min + int (angle * degrees)
    pwm.duty_u16(duty)  

  else:
    angle = 90
    duty = min + int (angle * degrees)
    pwm.duty_u16(duty)

BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT