In this project, we will learn how to make a laser-based security system with an LDR and an Arduino.

In this project, we will use a laser and an LDR to radiate light in a straight line. The LDR can detect the laser light if someone crosses it which means the laser light will be blocked. If the LDR is not able to detect the laser, the buzzer will alert us that somebody crossed or blocked the laser.

Step 1: Things You Need

000.jpg

For this project we will need the following things :

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

Step 2: Schematics


1111.jpg

Please connect everything according to the shown schematic above.

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

222.jpg
2222.jpg

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 the pushbutton. 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.

Utsource Parts
share how to, diy, homemade, circuit design and new project ideas.