Step 1: Things You Need

  • Arduino UNO Board
  • Laser Diode Module KY-008
  • Buzzer
  • LDR
  • Resistor (10k)
  • Push Button Switch
  • Bread Board
  • Connecting wires

Step 2: Schmatics

Please connect everything According to the shown schmatics.

Step 3: Code

Please copy the following code and upload it to the arduino Board :

int laserPin = 3;
int sensorPin = A0;
int buttonPin = 12;
int buzzerPin = 11;

int laserThreshold = 10;

void setup() {
pinMode(laserPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);

boolean alarmState = false;

void loop() {
if (! alarmState) {
digitalWrite(laserPin, HIGH);
unsigned long startTime = millis();
while (millis() - startTime < 1000) {
int sensorValue = analogRead(sensorPin);
if (sensorValue > laserThreshold) {
alarmState = true;
digitalWrite(laserPin, LOW);
} else {
tone(buzzerPin, 440);
if (! digitalRead(buttonPin)) {
alarmState = false;

Step 4: Testing the Security System

The project basically works on the principle of interruption. If by any means the LASER light is interrupted the alarm will start unless it is reset with push button. The laser is a concentrated light source that puts out a straight beam of light of a single color.

The LDR is sensitive to light and puts out a voltage when the laser light hits it. When the laser beam is interrupted and can’t reach LDR, its voltage output changes, and eventually the alarm will ring.