Open loop Alarm with Raspberry pi pico
#This is a micropython Script of an open loop Alarm
from machine import Pin,PWM
from utime import sleep
button_NC = Pin(16,Pin.IN,Pin.PULL_UP)#NC PB to Gp16 and GND via 10K resistance
led = Pin(15,Pin.OUT)
buzzer = PWM(Pin(13))
while True:
if button_NC.value()==1:
led.toggle()
buzzer.freq(500)#Buzzer will start to beep according to the frequency and duty.
buzzer.duty_u16(90000)
sleep(0.5)
buzzer.duty_u16(0)
sleep(0.05)
buzzer.duty_u16(1)
else:
led.off()
buzzer.deinit()
Comments
Post a Comment