Introduction: Laser Based Security System With Arduino

Hi guys in this instructables we will learn how to make a laser based security system with Arduino.
So basically we will use a laser and ldr laser to radiate light in a straight line and ldr to detect the laser light and if someone crosses it which means laser light will be blocked and LDR will not able to detect it then the buzzer will alert us that somebody crossed or blocked the laser.

Step 1: Things You Need

For this instructables we will need following things :

Arduino UNO Board :



LASER Diode Module KY-008 :



Buzzer :


LDR :



Resistors (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);
Serial.begin(9600);
}

boolean alarmState = false;

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

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.