Laser Diode & LDR based alarm system using Arduino

 In this Arduino electronics tutorial it is illustrated how to make laser based alarm system using Laser diode and LDR(Light Dependent Resistor). This can be useful to make security system for home usage or industrial application. It may also be useful in counting mechanism and control application. Arduino code for laser diode with LDR for alarm system is provided. Schematic wiring diagram of interfacing Arduino with LDR and buzzer, laser driver circuit with video demonstration are provided.

How it works

During normal operation, the laser beam from the laser diode hits the LDR. But when the laser beam is obstructed, LDR detects this because then it's resistance increases. This increase in resistance and hence increased voltage is detected by the Arduino ADC. When the increased voltage becomes higher than some per-defined voltage at normal condition, alarm is sounded using a buzzer by the Arduino. Hence whenever intruder crosses the laser beam line, alarm is sounded.

Interfacing & Schematic wiring drawing of interfacing Arduino, LDR, buzzer and laser driver 

The following picture shows implementation of interfacing Arduino with LDR and buzzer at the receiver and the laser diode driver circuit for the transmitter.
 
Laser Diode & LDR based alarm system using Arduino
 
The following is the circuit schematic diagram of wiring Arduino with LDR and buzzer at the receiver and the laser diode with laser diode driver circuit for the transmitter.

Laser Diode,LDR, Arduino alarm system circuit diagram
 
In the above circuit drawing, at the laser diode transmitter, the LM317 voltage regulator is used for driving constant voltage and current into the laser diode. The two resistors used in the laser driver circuit is 220Ohm and 270Ohm. The input supply is 5V and the output voltage is 2.78V. At the receiver, the LDR along with 10KOhm resistor forms a voltage divider circuit between 5V and ground. The middle of the voltage divider is connected to the Arduino analog pin A3. The Arduino ADC samples the voltage from this voltage divider. The sound buzzer for the alarm is connected to pin 4 of Arduino Nano.

Video demonstration of laser based alarm system


Arduino Code for Laser Diode LDR based alarm system

 
The following is the Arduino code for the laser based alarm system.
 
//Program for laserdiode based Alarm using LDR, Arduino, Buzzer
//Source: https://ee-diary.com


const int ldrPin = A3;
const int buzzerPin = 4;

void setup(){
  Serial.begin(9600); 		//set Serial output baud rate
  pinMode(buzzerPin, OUTPUT);

  //For output format
  Serial.println("\nADC value, Voltage(V):");
  Serial.println("--------------------------------------------------\n");
}

void loop() {
    int ldrValue = analogRead(ldrPin);
    float ldrVoltage = (ldrValue/1023.0)*5;

    if(ldrValue <= 350){
        digitalWrite(buzzerPin, HIGH);
      }
    else{
        digitalWrite(buzzerPin, LOW);
      }
    Serial.println(String(ldrValue)+","+String(ldrVoltage)+"V");
    delay(100); 	//100ms delayto prevent any duplicates
}
 

Proteus Simulation

 The following video shows simulation of the laser diode and LDR based alarm system using Arduino Nano concept in Proteus
 

 
The laser based alarm system is suitable for application where detection based on light beam are useful. Similar alarm system can be designed using only LDR(see Light Dependent Resistor (LDR) Light Detector Alarm with Arduino). Other alarm system can be designed using Infrared sensor and/or Photo Diode(Photodiode Light Detector with Arduino). Yet another kind of another alarm system was illustrated using keypad in the tutorial Password based Door Locking System using Arduino.

5 Comments

  1. Anonymous

    Hi ee-diary,
    Thank you very much for the educative valuable information on your posts. I am working on a similar project but using for different application.
    I will like to know how to integrate a regression equation to the output of LDR for example, y=(8*10^-5)x^2+0.1873x+46.131.
    In this, I was LDR output as the variable (x) in the equation.
    Your assistance is highly appreciated.
    Thank you

    Reply Delete June 26, 2022 at 1:22 PM
    1. ee-diary

      hmm, i don't understand clearly what is the input and what is the output? here laser could be input and LDR detection could be output, is that what you mean?

      Reply Delete June 26, 2022 at 5:28 PM
  2. Anonymous

    ee-diary, thanks for your response. LDR is the output and i call it (y) in the equation. The input is the laser and I call it (x). I need that LDR output to be integrated with the equation given above.

    Reply Delete July 2, 2022 at 12:32 PM
    1. ee-diary

      in the code, the ldrValue(or ldrVoltage) is y for your equation,there is no laser input(x). you can make your buzzer output as x by feeding it back to the laser input, however, for this you need to disassemble laser electronics.

      Reply Delete July 2, 2022 at 2:54 PM
  3. Anonymous

    Thanks for your response bro, I get your point. I need the ldr voltage to be incorporated with this equation:- y=(8*10^-5)x^2+0.1873x+46.131 so that I get a new output value which have been modified by that equation.
    That is why I was referring to the ldr voltage as (x) which will give a new output.
    I am working on a project using same principles of ldr voltage but that output have to be modified by the equation.
    My request is an Arduino code to perform the modification of ldr voltage with the equation.
    Your help is highly appreciated

    Reply Delete July 2, 2022 at 5:21 PM
Previous Post Next Post