from picozero import Speaker
from machine import Pin
from utime import sleep
from time import ticks_ms

push_bt = Pin(0, Pin.IN, Pin.PULL_UP)
# creating a Speaker object
speaker = Speaker(16)


# global value

speaker_is_playing = False
button_is_pressed = False
debounce_time=0
DEBOUNCE_WAIT_TIME=500

# Interrupt Service Routine for Button Pressed Events with debounce
def button_pressed(pin):
    global button_is_pressed
    global debounce_time
    if (ticks_ms() - debounce_time) > DEBOUNCE_WAIT_TIME:
        button_is_pressed = True
        debounce_time=ticks_ms()

# here is how we associate the falling value on the input pin with the callback function
push_bt.irq(handler=button_pressed, trigger=Pin.IRQ_FALLING)

while True:
    if (button_is_pressed == True):
        button_is_pressed = False
        if (speaker_is_playing == False):
            #tune=440, duration=1, volume=1, n=1, wait=True):
            speaker.on()
            speaker_is_playing = True
        else:
            speaker_is_playing = False
            speaker.off()

    sleep(0.05)

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