from machine import Pin, PWM
from time import sleep
print("Hello, Pi Pico!")
# lower right corner with USB connector on top
SPEAKER_PIN = 26
# create a Pulse Width Modulation Object on this pin
speaker = PWM(Pin(SPEAKER_PIN))
# set the duty cycle to be 50%
speaker.duty_u16(500)
speaker.freq(2000) # 50% on and off
sleep(5) # wait a second
speaker.duty_u16(0)