Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Laser Light Security System Using Arduino with Alarm
Arduino Projects

Laser Light Security System Using Arduino with Alarm

Mamtaz AlamBy Mamtaz AlamUpdated:July 26, 20261 Comment4 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Laser Light Security System Using Arduino wih Alarm
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Introduction

This project builds a Laser Light Security System using Arduino with an audible alarm. It uses a KY-008 laser diode module as the light source and an LDR (Light Dependent Resistor) as the detector. As long as the laser beam reaches the LDR, the system stays quiet. If anything blocks the beam, the Arduino detects the change and turns on the buzzer. The alarm keeps sounding until it is reset with a push button.

The same beam-break idea is used in museums, shops, warehouses, and home security setups. Commercial systems often use infrared (IR) beams that are harder to see. This DIY version uses a visible red 650 nm laser so the alignment and working principle are easy to understand and demonstrate.


Laser Light Security System Using Arduino with Alarm

Components Required

  1. Arduino UNO board
  2. Laser diode module KY-008
  3. Buzzer
  4. LDR (Light Dependent Resistor)
  5. 10 kΩ resistor
  6. Push button switch
  7. Breadboard
  8. Connecting wires

Circuit Diagram

Laser Light Security System Using Arduino with Alarm Circuit Diagram

Circuit Connections

  • KY-008 Laser module: Signal pin → Arduino digital pin 3; VCC → 5V; GND → GND
  • LDR sensor: Connected as a voltage divider with a 10 kΩ resistor to analog pin A0 (so the Arduino can read light level)
  • Buzzer: Positive/signal → Arduino digital pin 11; other side → GND
  • Push button: One side → Arduino digital pin 12; other side → GND (uses Arduino internal pull-up)

Place the laser and LDR facing each other so the red beam falls directly on the LDR surface. Keep the distance short and stable for reliable detection.


Laser Diode Module KY-008

KY-008 Laser Diode Module

The KY-008 is a small laser transmitter module for Arduino projects. It contains a 650 nm red laser diode and a series resistor on a tiny board. When powered and enabled, it emits a focused red dot/beam. Treat it as a Class 2-type laser pointer source: never look directly into the beam, and do not point it at eyes or reflective surfaces toward people.

KY-008 Specifications

  • Operating voltage: 5 V
  • Output power: about 5 mW
  • Wavelength: 650 nm (red)
  • Operating current: less than 40 mA
  • Working temperature: −10 °C to 40 °C (14 °F to 104 °F)
  • Dimensions: about 18.5 mm × 15 mm




Working Principle

This security system works on the beam-interruption principle.

Laser beam aligned with LDR sensor

  1. The KY-008 laser sends a narrow red beam toward the LDR.
  2. An LDR is a resistor whose resistance falls when light intensity rises. With the 10 kΩ resistor it forms a voltage divider, so Arduino pin A0 reads a voltage related to light level.
  3. When the beam hits the LDR, the analog reading stays low (bright condition).
  4. When a person or object blocks the beam, the LDR becomes darker, the analog reading rises above the set threshold, and the Arduino sets an alarm state.
  5. In alarm state, the buzzer sounds continuously.
  6. Pressing the push button clears the alarm state and stops the buzzer so the system can arm again.

A laser is used because it produces a narrow, nearly straight beam of one wavelength, which makes beam break detection sharp and reliable over a short distance compared with a normal LED.


Source Code / Program

Upload the following sketch to the Arduino UNO. Open Serial Monitor at 9600 baud to watch the LDR readings and adjust laserThreshold if needed for your lighting conditions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
int laserPin = 3;      // KY-008 signal pin
int sensorPin = A0;    // LDR voltage divider output
int buttonPin = 12;    // Reset push button
int buzzerPin = 11;    // Alarm buzzer
 
int laserThreshold = 10;  // Alarm if analog reading goes above this
 
void setup() {
  pinMode(laserPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);
  Serial.begin(9600);
}
 
boolean alarmState = false;
 
void loop() {
  if (!alarmState) {
    delay(1000);
    digitalWrite(laserPin, HIGH);   // Turn laser ON
    delay(10);
 
    unsigned long startTime = millis();
    while (millis() - startTime < 1000) {
      int sensorValue = analogRead(sensorPin);
      Serial.println(sensorValue);
 
      // Beam blocked / LDR dark → reading rises → trigger alarm
      if (sensorValue > laserThreshold) {
        alarmState = true;
        break;
      }
      delay(10);
    }
 
    digitalWrite(laserPin, LOW);    // Turn laser OFF between checks
  } else {
    tone(buzzerPin, 440);           // Sound alarm (440 Hz)
 
    // Press button (active LOW) to reset alarm
    if (!digitalRead(buttonPin)) {
      alarmState = false;
      noTone(buzzerPin);
    }
    delay(10);
  }
}

Code Explanation

  • laserPin, sensorPin, buttonPin, and buzzerPin define the hardware connections.
  • While not in alarm, the laser is turned on and A0 is sampled for about 1 second.
  • If the LDR reading crosses laserThreshold, alarmState becomes true.
  • In alarm state, tone() drives the buzzer until the button is pressed.
  • Because the button uses INPUT_PULLUP, a press reads as LOW and clears the alarm.

Video Demonstration

LASER based Security System with Alarm using Arduino & KY008
Watch this video on YouTube.


Related Projects

You can also build a similar laser security system using a 555 Timer & LDR or using a Raspberry Pi Pico & LDR.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleDIY Spiderbot Hexapod Robot using ESP32-CAM FOV
Next Article DIY Thermal Imaging Camera with MLX90640 & Raspberry Pi

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20259K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 202510K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
View 1 Comment

1 Comment

  1. paul on January 19, 2023 11:53 AM

    code is not working

    Reply

CommentsCancel reply

Latest Posts
Types of Diode : Overview, Symbol, Working & Applications

Types of Diode : Overview, Symbol, Working & Applications

July 26, 2026
ESP32 Patient Health Monitor (ECG, SpO₂, BPM) & Live Dashboard

ESP32 Patient Health Monitor (ECG, SpO₂, BPM) & Live Dashboard

July 26, 2026
Buck Converter vs Boost Converter

Buck Converter vs Boost Converter: Working, Differences & Applications

July 16, 2026
ESP32 Fingerprint Voting Machine with Live Web Dashboard

ESP32 Fingerprint Voting Machine with Live Web Dashboard

July 12, 2026
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

July 6, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
Top Posts & Pages
  • ESP32 Patient Health Monitor (ECG, SpO₂, BPM) & Live Dashboard
    ESP32 Patient Health Monitor (ECG, SpO₂, BPM) & Live Dashboard
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • Silicon Controlled Rectifier (SCR): Construction, Working & Applications
    Silicon Controlled Rectifier (SCR): Construction, Working & Applications
  • LD2410 Sensor with ESP32 - Human Presence Detection
    LD2410 Sensor with ESP32 - Human Presence Detection
Categories
  • Arduino Projects (197)
  • Articles (61)
    • Learn Electronics (20)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (207)
    • ESP32 MicroPython (7)
    • ESP32 Projects (84)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.