Making your own laser tripwire alarm with an Arduino is a fun electronics project that can be done on a budget. With just a few simple components, you can build a working alarm system to detect intruders crossing a laser beam.
What You Will Need
To build the laser tripwire alarm, you will need the following components:
Arduino Uno
The Arduino Uno is the microcontroller board that will control the alarm. It can be purchased for around $10.
Laser diode module
A laser diode module is used to produce the laser beam for the tripwire. These can be found for just a few dollars.
Photoresistor
A photoresistor or light dependent resistor (LDR) will detect when the laser beam is broken. Only a couple of dollars.
Resistors
Resistors are needed to properly control the laser and photoresistor. You'll need two 10K ohm resistors. Just a few cents each.
Breadboard
A breadboard is used to easily connect the components without soldering. Can be bought for around $5.
Jumper wires
Jumper wires connect the components on the breadboard. A bundle can be bought for a few dollars.
Buzzer
An electronic buzzer will sound the alarm when the beam is broken. Just $1-2.
9V battery & holder
A 9V battery and holder will power the alarm. Around $5 total.
So as you can see, all the components can be sourced for around $15!
How the Laser Tripwire Alarm Works
Here is a quick overview of how the DIY laser tripwire alarm works:
-
The laser diode beams a laser across a tripwire area.
-
The photoresistor detects this laser light.
-
When the laser beam is broken, such as by someone crossing it, the photoresistor detects the drop in light.
-
This triggers the Arduino to activate the buzzer alarm.
So breaking the laser beam with your hand or an object will sound the alarm. Pretty simple!
Now let's look at how to put the components together.
Setting Up the Circuit
The first step is to build the circuit on the breadboard.
-
Place the Arduino at one end of the breadboard.
-
Connect the laser diode and one 10K resistor to pin 3. The resistor controls the brightness.
-
Connect the photoresistor and other 10K resistor to pin A0. This resistor prevents false alarms.
-
The buzzer connects between pins 11 and GND.
-
Use jumper wires to make all the connections.
Here is a circuit diagram showing how everything should be connected:
With the circuit complete, now the code can be added.
Programming the Arduino
The Arduino code for the laser tripwire alarm does the following:
-
Initializes the laser and buzzer pins as outputs.
-
Sets the photoresistor pin as an input.
-
In a loop, it reads the photoresistor value.
-
If this value drops below a threshold, it triggers the alarm.
Here is the full Arduino sketch:
```cpp
// Set pin numbers
const int laser = 3;
const int buzzer = 11;
const int photoresistor = A0;
// Threshold for triggering alarm
int threshold = 400;
void setup() {
// Set laser and buzzer as outputs
pinMode(laser, OUTPUT);
pinMode(buzzer, OUTPUT);
// Set photoresistor pin as input
pinMode(photoresistor, INPUT);
}
void loop() {
// Read photoresistor value
int val = analogRead(photoresistor);
// Check if beam is broken
if (val < threshold) {
// Trigger alarm
digitalWrite(buzzer, HIGH);
}
else{
// Disable alarm
digitalWrite(buzzer, LOW);
}
delay(10);
}
```
This code can be uploaded to the Arduino board using the Arduino IDE.
Now it's ready to test!
Testing and Using the Laser Tripwire
To test the alarm:
-
Upload the code and power the Arduino.
-
Position the laser and photoresistor facing each other across a gap.
-
Break the beam with your hand or an object.
-
The alarm should sound whenever the beam is blocked!
To use the tripwire:
-
Mount the laser and photoresistor on stands pointing at eachother across a doorway or area you want to protect.
-
Align them so the photoresistor receives the laser light.
-
When anyone passes between and blocks the beam, the alarm will activate.
Troubleshooting
If the alarm isn't working, double check the wiring matches the circuit diagram. Also try adjusting the threshold value up or down until the alarm reliably triggers.
And that's it! With just a few cheap components, you can build your own DIY Arduino laser tripwire alarm for under $15.