from machine import Pin, PWM
from utime import sleep
# creating a PWM object
buzzer = PWM(Pin(15, Pin.OUT))
# Settings
buzzer.freq(1000)
push_bt = Pin(0, Pin.IN, Pin.PULL_UP)
while True:
print("push btn = ", push_bt.value())
if (push_bt.value() == 0):
#tune=440, duration=1, volume=1, n=1, wait=True):
buzzer.duty_u16(32768)
else:
buzzer.duty_u16(0)
sleep(0.5)