from machine import Pin
from time import sleep
from picozero import Speaker
swt=Pin(9,Pin.IN,Pin.PULL_UP)
led=Pin(5,Pin.OUT)
buz=Speaker(17)
while True:
tsr=swt.value()
print(tsr)
if tsr==0:
print("switch is OFF")
led.off()
buz.on()
else:
print("switch is ON")
led.on()
buz.off()