How to Build a Laser Tripwire Alarm Demo with Arduino
Detect a broken light beam with an LDR and sound a buzzer
Updated

What you'll build
This guide walks you through a safe laser tripwire alarm demo with an Arduino Uno, a light-dependent resistor, a 10k resistor, a piezo buzzer, and a low-power laser module or pointer. The laser shines at the LDR. While the beam is aligned, the Arduino sees a bright analogue reading and stays quiet. When something blocks the beam, the reading drops below a threshold, the buzzer sounds, and the sketch prints an alert to Serial.
The project is scoped as a learning build, not a real security system. You will build a voltage divider for the LDR, calibrate the light threshold from real Serial Monitor readings, drive a buzzer with tone(), and keep the laser under firmware control from a digital output. The recovered Schematik generation used an Arduino Uno with an LDR, 10k resistor, piezo buzzer, and low-power laser, with the beam-break logic triggering an "intruder detected" message.
When complete, you'll have a small desk demo that makes the sensor behaviour obvious: align the beam, watch the readings, block it with a card, and hear the alarm. Use it to learn analogue input thresholds and hysteresis before moving on to better enclosure design, a visible status LED, or a Bluetooth/serial notification layer. Keep the safety rule simple: low-power visible laser only, never aim it at eyes, faces, pets, windows, or reflective surfaces.
Wiring diagram
Wiring diagram
Components needed
Assembly
Build the LDR divider
Place the LDR so one leg goes to 5V and the other leg shares a row with A0. Add the 10k resistor from that same A0 row to GND.
- Point the laser at the LDR before powering the circuit.
- Use only a low-power visible laser and never aim it at eyes, pets, reflective surfaces, or people.
Wire the laser and buzzer
Connect the laser module signal to D2, VCC to 5V, and GND to GND. Connect the buzzer signal to D5 and its negative leg to GND.
- Share a common ground across the laser, buzzer, and LDR divider.
- This is a toy alarm demo, not a real security or access-control system.
Upload and calibrate
Upload the sketch, open Serial Monitor at 9600 baud, and note the LDR readings with the beam hitting and missing the sensor. Adjust LDR_THRESHOLD if your readings sit above or below 400.
- Increase the threshold if the buzzer never fires; decrease it if it fires while the beam is aligned.
Pin assignments
| Pin | Connection | Type |
|---|---|---|
| 5V | laser-module-1 VCC | POWER |
| GND | laser-module-1 GND | GROUND |
| GPIO 2 | laser-module-1 SIG | DIGITAL |
| 5V | ldr-1 VCC | POWER |
| GPIO 14 | ldr-1 AO | ANALOG |
| GPIO 14 | resistor-10k-1 Divider node → ldr-1:AO | ANALOG |
| GND | resistor-10k-1 GND | GROUND |
| GPIO 5 | buzzer-1 SIG | DIGITAL |
| GND | buzzer-1 GND | GROUND |
Code
#include <Arduino.h>
const int LASER_PIN = 2;
const int BUZZER_PIN = 5;
const int LDR_PIN = A0;
const int LDR_THRESHOLD = 400;
void setup() {
Serial.begin(9600);
pinMode(LASER_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(LDR_PIN, INPUT);
digitalWrite(LASER_PIN, HIGH);
noTone(BUZZER_PIN);
Serial.println("Laser tripwire demo ready");
}
void loop() {
int lightLevel = analogRead(LDR_PIN);
Serial.print("LDR value: " );
Serial.println(lightLevel);
if (lightLevel < LDR_THRESHOLD) {
tone(BUZZER_PIN, 1000);
Serial.println("Intruder detected: beam broken");
} else {
noTone(BUZZER_PIN);
}
delay(100);
}
// Run this and build other cool things at schematik.ioReady to build this?
Open this project in Schematik to get the full wiring diagram, pin assignments, and deployable code for the Laser Tripwire Alarm Demo.
Open in Schematik →