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

Popular posts from this blog

Proteus simulation 4x4 Matrix Keypad with Arduino and LCD screen

Digital Clock with Arduino and RTC Module and P10 LEDmatrix

Interfacing KY038 sound sensor with Raspberry pi Pico