How to Build a Laser Tripwire Alarm Demo with Arduino

Detect a broken light beam with an LDR and sound a buzzer

Arduino UnoSecurityBeginner30 minutes4 components

Updated

How to Build a Laser Tripwire Alarm Demo with Arduino
For illustrative purposes only
On this page

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

Interactive wiring diagram

Components needed

ComponentTypeQtyBuy
Low-power laser moduleactuator1€2.90
LDR photoresistorsensor1
10k resistorpassive1€4.90
Piezo buzzeractuator1€4.75

Prices and availability are indicative and may have been updated by the supplier. Schematik may earn a commission from purchases made through affiliate links.

Assembly

1

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.

2

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.

3

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.

Pin assignments

PinConnectionType
5Vlaser-module-1 VCCPOWER
GNDlaser-module-1 GNDGROUND
GPIO 2laser-module-1 SIGDIGITAL
5Vldr-1 VCCPOWER
GPIO 14ldr-1 AOANALOG
GPIO 14resistor-10k-1 Divider node ldr-1:AOANALOG
GNDresistor-10k-1 GNDGROUND
GPIO 5buzzer-1 SIGDIGITAL
GNDbuzzer-1 GNDGROUND

Code

Arduino C++
#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.io

Ready 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 →

Related guides