from machine import Pin, PWM
from utime import sleep
led=Pin(3, Pin.OUT)
reed_sw= Pin(6, Pin. IN, Pin.PULL_UP)
buzzer=PWM((Pin(18)))
buzzer.deinit()
led. value(1)
while (1):
if(reed_sw.value()==0):
buzzer.deinit()
led. value(1)
sleep(0.3)
led. value (0)
sleep(0.8)
else:
buzzer.duty_u16(32767)
buzzer. freq (500)
led. value (1)
sleep (0.1)
led. value(0)
sleep (0.2)