Accéder au contenu principal

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.

Grove Light Sensor v1.2




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 1.png
5V/GND and Sign with A0


#define Rec 0

void setup() {

void loop() {



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


When exposed to light, around 760 is the highest value
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 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.


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(){
  for(short i=0 ; i<4 ; i++)
           char keypressed = myKeypad.waitForKey();
              if (keypressed==code[i])

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.




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


You can download the second code here.


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



Yassine Tout afficher

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


Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:


Vous commentez à l'aide de votre compte Déconnexion /  Changer )

Photo Google

Vous commentez à l'aide de votre compte Google. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s

%d blogueurs aiment cette page :