laser beam interrupt alarm system

 


'''This is a laser Beam Alarm System.
(if any oject interrupt the lazer beam to the ldr sensor- an alrm will trigger)'''


import utime

from machine import Pin, PWM

from utime import sleep


buzzer = PWM(Pin(13))

led = Pin(15,Pin.OUT)

laser_sensor = machine.ADC(26)

while True:

    print(laser_sensor.read_u16())

    utime.sleep(2)

                        

    if laser_sensor.read_u16()<= 5000:#if laser sensor value is less than or equal to 5000

        print(" Alarm Triggered")

        led.on()

        buzzer.freq(500)

        buzzer.duty_u16(90000)

        sleep(0.9)

        buzzer.duty_u16(1)

        sleep(0.01)

        buzzer.duty_u16(0)

    else:

        print("System Normal")

        led.off()

        buzzer.deinit()


Comments

Popular posts from this blog

4 Stage Timer With DS3231RTC Module.

Interfacing KY038 sound sensor with Raspberry pi Pico

Interfacing MQ2 Gas & Smoke Sensor With Raspberry Pi Pico