from machine import Pin, PWM, ADC
from time import sleep_ms

buzzer = PWM(Pin(20))
buttons = ADC(26)

def play_note(freq, duration=100):
    buzzer.freq(freq)
    buzzer.duty_u16(32768)
    sleep_ms(duration)
    buzzer.deinit()

buzzer.duty_u16(32768)
while True:
    val = buttons.read_u16()
    print(val)
    buzzer.freq(int(400*val/65535))
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT