Trybotics Logo

LASER Tripwire Alarm - Arduino © GPL3+

DESCRIPTION

Full Tutorial video if needed

Hi, this tutorial is about "Grove Light Sensor" based project, there are two versions of the project, and as you read it it's a LASER Tripwire Alarm, one that you can set with a simple push button, the other one is more secure and requires a passcode.

A tripwire is a device triggered by physical movements, you can use it to detect people, animals, cars... when they pass through an area. This one is based on a LASER emitter, that constantly sends beams to the light sensor, and when someone/something passes, the sensor won't receive the beams, and the alarm is triggered, and won't stop until you resest it (push button/passcode).

Parts

Those are the parts used along side some jump wires

Version 1

This project is based on the module, LASER module, a Buzzer, and a push button, the idea is very simple, the LASER is constantly projecting light to the module sensor, when a person or something passes through the light beam, the sensor will not detect the light anymore (When the light stops, the LDR will increase resistance, which means less current will pass, and we’ll get a voltage drop).

Example: At indoor light the sensor will give a value of around “750” when using the “analogRead” function while using Arduino it’s around “3.66V” (1023 for 5V), but when you cover the sensor it will show a value around “10-15” that stands for “40mV”. So it’s better to cover or put the sensor in a case where only the LASER beams can reach.

Once the LASER beams are cut, the alarm will go off and will not stop until the push button is pressed even though the module detects the LASER again.

Below you'll find wiring and code

Version 2

The v2 is pretty much like the v1 just instead of stopping the alarm with a simple push button, now it requires a passcode entered by the keypad to stop it, otherwise it won’t.

The passcode is stored in an array, I chosed 4 digits code, you can make it longer or shorter, just modify the array size, and add or remove values.

short code[4]={'1','3','6','6'}; 

To turn the alarm off, you should press ‘*’ on the keypad, then enter the numbers 1, 3, 6, 6, the code will fix the buzzer in a single frequency (disturbing) sound until you enter 4 digits, if they are correct the alarm will stop, otherwise it will go off again.

void Getpass(){ tone(13,2000); for(short i=0 ; i<4 ; i++)  {  char keypressed = myKeypad.waitForKey();  if (keypressed==code[i])  a++;  } } 

Every time you enter a correct digit “a” value increases, if it’s == 4, the code is considred correct, otherwise the number will never be equal to 4.

 if(a==4){  noTone(13);  a=0;  detection=false;  } 

Test

This is a test video for both versions, the video is loud !!!

Test video

Description:

A000066 iso both
Arduino UNO & Genuino UNO
×1
101020014 201
Seeed Grove - Light Sensor
×1
ky 008 Laser emitter
×1
Adafruit industries ada1536 image
Buzzer
×1
Push Button
×1
4x4 keypad matrix
×1

Description:

Full Tutorial video if needed

Hi, this tutorial is about "Grove Light Sensor" based project, there are two versions of the project, and as you read it it's a LASER Tripwire Alarm, one that you can set with a simple push button, the other one is more secure and requires a passcode.

A tripwire is a device triggered by physical movements, you can use it to detect people, animals, cars... when they pass through an area. This one is based on a LASER emitter, that constantly sends beams to the light sensor, and when someone/something passes, the sensor won't receive the beams, and the alarm is triggered, and won't stop until you resest it (push button/passcode).

Parts

Those are the parts used along side some jump wires

Version 1

This project is based on the module, LASER module, a Buzzer, and a push button, the idea is very simple, the LASER is constantly projecting light to the module sensor, when a person or something passes through the light beam, the sensor will not detect the light anymore (When the light stops, the LDR will increase resistance, which means less current will pass, and we’ll get a voltage drop).

Example: At indoor light the sensor will give a value of around “750” when using the “analogRead” function while using Arduino it’s around “3.66V” (1023 for 5V), but when you cover the sensor it will show a value around “10-15” that stands for “40mV”. So it’s better to cover or put the sensor in a case where only the LASER beams can reach.

Once the LASER beams are cut, the alarm will go off and will not stop until the push button is pressed even though the module detects the LASER again.

Below you'll find wiring and code

Version 2

The v2 is pretty much like the v1 just instead of stopping the alarm with a simple push button, now it requires a passcode entered by the keypad to stop it, otherwise it won’t.

The passcode is stored in an array, I chosed 4 digits code, you can make it longer or shorter, just modify the array size, and add or remove values.

short code[4]={'1','3','6','6'};

To turn the alarm off, you should press ‘*’ on the keypad, then enter the numbers 1, 3, 6, 6, the code will fix the buzzer in a single frequency (disturbing) sound until you enter 4 digits, if they are correct the alarm will stop, otherwise it will go off again.

void Getpass(){  
tone(13,2000);  
for(short i=0 ; i<4 ; i++)           
 {                         
      char keypressed = myKeypad.waitForKey();             
      if (keypressed==code[i]) 
      a++;           
 }
}

Every time you enter a correct digit “a” value increases, if it’s == 4, the code is considred correct, otherwise the number will never be equal to 4.

 if(a==4){         
   noTone(13);        
   a=0;         
   detection=false;
         }

Test

This is a test video for both versions, the video is loud !!!

Test video

Description:

Laser_Tripwire_Alarm_Button.inoArduino
This code works with the version 1
/* This code is for a LASER Tripwire Alarm based on a light sensor, LASER module and a push button
 * The LASER is constantly sending beams to the sensor, when someone passes the light is not detected
 * and the alarm goes off, and will not stop until you press the button
 * Refer to www.surtrtech.com for more details
 */
 
#define Rec 0      //Light sensor output
#define Laser 2    //Laser module 
#define Button 3   //Push button input

bool detection;

void setup() {
  pinMode(Laser, OUTPUT);
  digitalWrite(Laser, HIGH); //Turning on the laser
  delay(2000);
}

void loop() {

 short Detect = analogRead(Rec);            //Constanly reading the module value
 bool  Button_state = digitalRead(Button);  //And the button value (1-0)
 
 if(Detect < 500)              //The Max value is 760, if someone passes it goes below that (every value lower than 700 can do the work)
    detection = true;          //The detection is triggered

 if(detection==true)
    {
       tone(13,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(13,1000);
       delay(50);
    }
 
 if(Button_state == HIGH)  //If the button is pressed the buzzer is turned off and the detection too
    {
      detection = false;
      noTone(13);
    }

  
}
Laser_Tripwire_Alarm_Keypad.inoArduino
This code works with the version 2
/* This code is for a LASER Tripwire Alarm based on a light sensor, LASER module and keypad
 * The LASER is constantly sending beams to the sensor, when someone passes the light is not detected
 * and the alarm goes off, and will not stop until you press '*' and enter the correct code
 * Refer to www.surtrtech.com for more details
 */

#include <Keypad.h>

#define Rec 0
#define Laser 2
#define Button 3

bool detection;
short a=0;
short code[4]={'1','3','6','6'};  //pass code stored in a array you can make it longer or shorter
                                  //by changing '4' and add/remove values

const byte numRows= 4;            //Rows and columns of the keypad
const byte numCols= 4;
 
char keymap[numRows][numCols]=    //Keypad map
          {
          {'1', '2', '3', 'A'}, 
          {'4', '5', '6', 'B'}, 
          {'7', '8', '9', 'C'},
          {'*', '0', '#', 'D'}
          };

byte rowPins[numRows] = {11,10,9,8}; //Keypad 8 pins
byte colPins[numCols]= {7,6,5,4}; 

Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

void setup() {
  
  pinMode(Laser, OUTPUT);
  digitalWrite(Laser, HIGH);
  delay(2000);
}

void loop() {

 short Detect = analogRead(Rec);                 //Constantly reading the sensor value, to detect if someone passes


    if(Detect < 500)
        detection = true;

    if(detection==true) 
        {                                       //Alarm sequence and constantly waiting for '*' to be pressed
         tone(13,1000);
         delay(50);
         tone(13,200);
         delay(50);
         char keypressed = myKeypad.getKey();
         if (keypressed == '*')                   //if '*' is pressed go to Getpass function
         Getpass();
          }
    
     if(a==4){                                   //if a==4 means the code is correct, the alarm is off
         noTone(13);
         a=0;                                   //setting the a to 0, otherwise the alarm will turn off automatically
         detection=false;
         }
 
  
}

void Getpass(){               //Getting passcode function
  tone(13,2000);              //Constant frequency sound while entring the code
  for(short i=0 ; i<4 ; i++)
            {
              
           char keypressed = myKeypad.waitForKey();
              if (keypressed==code[i])   //If the sequence is correct the a increases (4) means all values are right
              a++;
            }
}

Description:

Wiring for V1
Wiring 2 ciadquxxdi
Wiring for V2
Wiring 3 ivdtgmuski


YOU MIGHT ALSO LIKE