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
- Arduino UNO board
- Laser diode module KY-008
- Buzzer
- LDR (Light Dependent Resistor)
- 10 kΩ resistor
- Push button switch
- Breadboard
- Connecting wires
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
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.
- The KY-008 laser sends a narrow red beam toward the LDR.
- 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.
- When the beam hits the LDR, the analog reading stays low (bright condition).
- 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.
- In alarm state, the buzzer sounds continuously.
- 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, andbuzzerPindefine 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,alarmStatebecomes 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
Related Projects
You can also build a similar laser security system using a 555 Timer & LDR or using a Raspberry Pi Pico & LDR.










1 Comment
code is not working