How to make a Laser Tripwire Alarm using Arduino.

How to make a Laser Tripwire Alarm using Arduino.
A laser tripwire is a device triggered by physical movements. It can be used for security in order to detect unwanted intruders in an areas like bank vaults, military establishments and even homes.

How does the laser tripwire work?

This tripwire is made of mainly a laser diode for transmitting a laser beam and a laser sensor which detects the beam. A light dependent resistor can also be used as the laser sensor.
laser diode and laser sensor modules
The laser transmitter module has three pins but only two pins are used: the “-” pin is connected to Arduino GND pin and the “S” pin is connected to the Arduino 5V.
The laser sensor module has three pins.The “VCC” pin is connected to the Arduino 5V, the GND of the module is connected to the Arduino GND. and the signal pin ”OUT” is connected to a digital pin of the Arduino.

The laser transmitter diode emits a laser beam that is constantly focused onto the sensor. When anything passes through the beam, the sensor won’t receive the beam and this triggers a warning system like an alarm.

I recommend the links below if you want to buy a laser transmitter, laser sensor or light dependent resistor.
  • KY-008 Laser Transmitter:……..  Amazon
  • Laser Sensor:……………………  Amazon
  • Light Dependent Resistors:……  Amazon
  • Disclosure: These are affiliate links. I earn a commission as an Amazon Associate for qualifying purchases. I would appreciate your support in this way.

    A simple laser tripwire alarm using Arduino.

    The alarm is setup as shown below where the laser sensor will be connected to any digital pin of the Arduino and a buzzer is connected to any other digital pin .The laser diode is only connected to GND and VCC. The emitted laser beam is focussed onto the sensor.
    laser tripwire with alarm schematic

    CODE

    #define LASER_SENSOR 2 // pin 2 for  sensor
    #define BUZZER 8 // pin 8 for buzzer
    
    void setup() {
      pinMode(BUZZER, OUTPUT);
    }
    
    void loop() {
      
      int laser = digitalRead(LASER_SENSOR );// read Laser sensor
      if( laser == HIGH)
      {
        tone(BUZZER, 2000);
    
      }else{
         noTone(BUZZER);
      }
      delay(200);
    }
    
    
    
    When the above code is uploaded to the Arduino board, the buzzer will sound whenever anything cuts the laser beam and when the beam is not cut, the buzzer will not sound.

    Improving the tripwire alarm.

    The setup given above has a major weakness, that is, not giving the person controlling the security system ability to know whether there was a security bleach or not because not everything that cuts through the beam will enter the restricted area.
    This can be solved by including another system for stopping the alarm only after confirming whether there was a security bleach or not. In this case we can add a switch. When the laser beam is cut, the buzzer will sound and will not go off until the switch is pressed.

    CODE

    #define BUZZER 8      
    #define LASER_SENSOR 2   
    #define SWITCH 3   
    
    void setup() {
      pinMode(BUZZER, OUTPUT);
      pinMode(SWITCH,INPUT_PULLUP ); 
    }
    
    void loop() {
    
     int laser = digitalRead(LASER_SENSOR);            //Constanly reading the module value
     bool  Button_state = digitalRead(SWITCH);  //And the button value (1-0)
     
     if(laser == HIGH)
        {
           tone(BUZZER,2000);        //Alarm sequence will go on as long as the detection is true
           delay(50);            //This alarm has two sounds 2kHz nd 1Khz delayed by 50ms
           tone(BUZZER,1000);
           delay(50);
        }
     
     if(Button_state == HIGH)  //If the button is pressed the buzzer is turned off and the detection too
        {
          noTone(BUZZER);
        }
          
    }
    
    

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Back to top