Skip to content

LASER Tripwire Alarm with Arduino

 

Hello, and welcome to another tutorial sponsored by Seeed Studio, the other one was a Speech recognition module, many thanks for them, today we have a Light Sensor module, you can get the module here: Buy module here from Seeed Studio.

Check the module wiki here.

Light_sensor_1
Grove Light Sensor v1.2

Light_sensor_2

 

Parts

Interfacing the module

The module is very easy to interface with the Arduino board, the module has a 4-pins grove connector, GND, 5V, and an analog output, the other pin is not connected, and as you tought, the output signal changes depending on the light detected.

Wiring

Wiring 1.png
5V/GND and Sign with A0

Code

#define Rec 0

void setup() {
Serial.begin(9600);
}

void loop() {

Serial.println(analogRead(Rec));

}

This is the easiest code to test the module, we just read the analog value and display it on the Serial Monitor.

Test

Test_1_1
When exposed to light, around 760 is the highest value
Test_1_2
When covered the value is around 10

And the value changes depending on the lighting

Tripwire Alarm v1

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.

Wiring

 

Wiring 2.png
Buzzer with 3.3v/Gnd and I/O with D13, Laser vcc is wired with D2, and the button with D3

You can power the laser as I do or just wire it with 5v to be constantly powered on.

Code

You can download the code here.

 

Tripwire Alarm v2

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.

if you’re not familiar with keypad, check this tutorial.

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;
         }

 

Wiring

Wiring 3.png
I used a 4*4 keypad matrix you can use 3*4

Code

You can download the second code here.

Tests

This short video shows tests for both versions (It’s loud!!)

 

Yassine View All

Electronics, Automation engineering student... I try to share my little experience with other electronics amateur.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: