Laser Tripwire Box with LCD Alert Using Arduino Uno

 

Laser Tripwire Alarm System using Arduino Uno, Laser Module, and LDR Sensor

01 Overview

This simple project involves creating a laser trip wire using an Arduino Uno. It integrates a laser module as its light source and an LDR module as its trigger, using an LCD module to provide real-time sensor status and visual feedback. The text displayed on the LCD cycles between "INTRUDER ALERT", "TRIPWIRE ACTIVATED", and "MONITORING: BEAM INTACT" monitoring states.

Laser Safety: Never point the laser module at eyes or reflective surfaces. Handle with care during setup and testing.

02 Hardware and Software Components

Gather everything below before you start.

Hardware Components

Component Description
Arduino Uno with USB Cable Main microcontroller that reads the LDR, controls the laser, drives the buzzer, and updates the LCD.
Breadboard Platform for building and testing the tripwire circuit.
Laser Module (KY-008) Acts as the light source that forms the tripwire beam.
LDR Light Sensor Module Detects when the laser beam is interrupted, triggering the alert state.
10kΩ Resistor Forms a voltage divider with the LDR for a stable, readable analog signal on A0.
Passive Buzzer Module 5V (FC-07) Sounds the intruder alert tone when the beam is broken.
Push Button Resets the system and silences the alert after a trigger event.
14500 Li-ion Battery 3.7V/1200mAh Portable power source for standalone, untethered operation.
LCD Module 16x02 with I2C Displays real-time system status: ready, monitoring, alert, and reset messages.
Jumper Wires Connects all modules to the Arduino and breadboard.
2x Battery Holder 14500 with Knife/Switch Houses the batteries and provides an on/off switch for the power supply.

Software Tools

Software Description
Arduino IDE Used to write, compile, and upload the tripwire sketch to the Arduino Uno.
LiquidCrystal_I2C Library (by Frank de Brabander) Arduino library used to drive the 16x2 I2C LCD module.

03 Application Discussion

Arduino Uno R3

We're using an Arduino Uno as the main microcontroller for this project. It is a popular open-source microcontroller board based on the ATmega328P microcontroller.

Laser Module (KY-008)

KY-008 Laser Module

Pinout

Arduino Laser Module: Connecting KY-008 to Arduino

The KY-008 is a compact, low-cost red laser transmitter module which integrates a 650 nm red laser diode, a current-limiting resistor, and three male header pins on a PCB. Designed for easy interfacing with Arduino, ESP32, Raspberry Pi, and similar boards, it's ideal for simple laser pointer functions, optical communication, or creating laser tripwire setups. Handle with care — never point the laser at eyes or reflective surfaces.

Specifications:

Feature Specification
Laser Wavelength 650 nm (red beam)
Output Power ≤ 5 mW (Class IIIa/3A laser)
Operating Voltage 5 V (some sources suggest 3–5 V)
Operating Current ~30–40 mA
Temperature Range −10°C to +40°C
Module Size ~18.5 × 15 mm (PCB); some list 15 × 24 mm
Heat & Regulation Simple resistor-based current limiting; may heat under long operation

LDR Light Sensor Module

LDR Light Sensor Module

Pinout

Pin Function
VCC 5V
GND GND
OUT Signal output

The K853518 is a classic analog light sensor module based on a Light Dependent Resistor (LDR). It uses a simple voltage divider circuit and outputs a voltage proportional to ambient light levels. Ideal for Arduino, ESP32, Raspberry Pi Pico (with external ADC), etc.

Key Specifications:

  • Operating Voltage: 3.0–5.5 V DC
  • Output Type: Analog voltage (direct output)
  • Layout & Dimensions: PCB with two mounting holes (~3 mm); board size ≈ 29 × 21 × 9.5 mm; weight ~2 g
  • Analog Range: Voltage varies linearly with light — higher in bright, lower in dark
  • LDR Characteristics (typical for similar modules): Dark ≈ 50 kΩ → Bright < 500 Ω
  • Signal Cable: 20 cm 3-wire cable included (VCC, GND, OUT)

Passive Buzzer Module 5V (FC-07)

Passive Buzzer Module FC-07

Pinout

How to Interface A Passive Buzzer Module with Arduino - ElectroPeak

A compact PWM-driven sound module using a passive piezo buzzer. Requires a microcontroller to send square-wave signals (2–5 kHz typically) to produce sounds like tones or melodies. It doesn't buzz with steady DC voltage — only with oscillating signals.

Key Specifications:

Feature Details
Operating Voltage 3.3–5 V DC
Rated Current < 30 mA typical
Drive Signal Frequency PWM square-wave, ~1.5–5 kHz (resonant freq ≈ 2.5 kHz)
Sound Level ≥ 85 dB @ 10 cm
PCB Size ~20 × 20 mm (some ~33 × 13 × 10 mm)
Weight ~3 g
Module Includes Often includes LED indicator, S8550 driver transistor, and a 3-pin cable

LCD Module 16x02 with I2C

LCD 16x02 with I2C backpack

Pinout

In-Depth: Interfacing an I2C LCD with Arduino

This module combines a standard 16×2 character LCD (HD44780-compatible) with an I2C "backpack" module, drastically simplifying wiring — just four wires: VCC, GND, SDA, and SCL. It's ideal for microcontrollers like Arduino, ESP32, Raspberry Pi, and more.

04 Hardware Setup

Wiring Diagram:

Laser Tripwire wiring diagram

Follow the step-by-step build guide below.

Step 1 — Gather Your Components

  • Arduino Uno
  • Laser Module (KY-008)
  • LDR Sensor (KY-018 or Keyes K853518)
  • 10kΩ resistor
  • Passive Buzzer (FC-07)
  • Push Button
  • LCD 16x2 with I2C module
  • Breadboard
  • Jumper wires (male-to-male)
  • 5V battery pack or USB power bank
  • USB cable (if using power bank)

Step 2 — Power Setup

  1. If using a USB power bank:
    • Plug the USB cable into the Arduino's USB port.
    • This powers the Arduino and the 5V rail safely.
  2. If using a 5V battery pack with open wires:
    • Connect Battery + (red) to Arduino 5V pin.
    • Connect Battery − (black) to Arduino GND pin.
  3. On the breadboard, connect:
    • Arduino 5V → red power rail
    • Arduino GND → blue ground rail

Step 3 — Wire the LCD (I2C 16x2)

LCD Pin Connect To
VCC Breadboard 5V
GND Breadboard GND
SDA Arduino A4
SCL Arduino A5

Step 4 — Wire the Laser Module (KY-008)

Laser Pin Connect To
VCC Breadboard 5V
GND Breadboard GND
Signal Arduino D9 (LASER_PIN)

Step 5 — Wire the LDR + 10kΩ Resistor (Voltage Divider)

  1. Place LDR across two breadboard rows.
  2. Connect:
    • One LDR leg → Breadboard 5V rail
    • Other LDR leg → Arduino A0 (LDR_PIN) AND one end of a 10kΩ resistor
    • Other end of the resistor → Breadboard GND rail

Step 6 — Wire the Passive Buzzer (FC-07)

Buzzer Pin Connect To
VCC Breadboard 5V
GND Breadboard GND
Signal Arduino D8 (BUZZER_PIN)

Step 7 — Wire the Push Button

  1. Connect one leg of the push button → Arduino D6 (BUTTON_PIN)
  2. Connect the other leg → Breadboard GND rail
  3. (No need for an external resistor — INPUT_PULLUP is enabled in code.)

Step 8 — Upload the Code

  1. Open Arduino IDE.
  2. Paste the provided sketch (see Code section).
  3. Make sure the LiquidCrystal_I2C library is installed.
  4. Connect the Arduino to your PC and upload the sketch.

Step 9 — Test and Calibrate

  • Power up the system using your battery pack or USB power bank.
  • The LCD should display "System Ready".
  • Aim the laser beam directly at the LDR.
  • When the beam is blocked, the buzzer should sound, and the LCD should say "INTRUDER ALERT".
  • Press the button to reset the system.

Step 10 — Enclosure Building

Drill holes and follow the initial plan for the enclosure. Use non-conductive adhesive to build the device with the enclosure provided.

Tip: Adjust LDR_THRESHOLD in the code if the trigger is too sensitive or not triggering at all.

05 Software Setup

Follow these steps before uploading the sketch.

Step 1 — Install Arduino IDE

Download and install the latest version of Arduino IDE, then select Arduino Uno under Tools → Board and the correct COM port under Tools → Port.

Step 2 — Install the Library

Open Arduino IDE → Sketch → Include Library → Manage Libraries, then install LiquidCrystal I2C by Frank de Brabander.

06 Code

Below is the complete Arduino sketch used for the project. Read the Code Breakdown section to understand what each part does.

Laser Tripwire Sketch

Arduino / C++
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

// Pin definitions
#define LDR_PIN A0
#define LASER_PIN 9
#define BUZZER_PIN 8
#define BUTTON_PIN 7

#define LDR_THRESHOLD 600
#define DEBOUNCE_DELAY 50  // milliseconds

bool alertTriggered = false;
bool buttonPressed = false;
unsigned long lastDebounceTime = 0;
int lastButtonState = HIGH;

void setup() {
  pinMode(LDR_PIN, INPUT);
  pinMode(LASER_PIN, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP); // Internal pull-up

  digitalWrite(LASER_PIN, HIGH); // Turn on laser

  Serial.begin(9600);
  lcd.init();
  lcd.backlight();

  lcd.setCursor(0, 0);
  lcd.print("Laser Tripwire");
  lcd.setCursor(0, 1);
  lcd.print("System Ready");
  delay(2000);
  lcd.clear();
}

void loop() {
  int ldrValue = analogRead(LDR_PIN);
  int reading = digitalRead(BUTTON_PIN); // Current button state

  Serial.print("LDR Value: ");
  Serial.print(ldrValue);
  Serial.print(" | Button: ");
  Serial.println(reading == HIGH ? "PRESSED" : "NOT PRESSED");

  // Debounce logic
  if (reading != lastButtonState) {
    lastDebounceTime = millis(); // reset debounce timer
  }
  // If button is pressed
  if ((millis() - lastDebounceTime) > DEBOUNCE_DELAY) {
    // if the button state has been stable for the debounce delay
    if (reading == LOW && !buttonPressed) {
      buttonPressed = true; // button press confirmed

      if (alertTriggered) {
        Serial.println("Button confirmed: RESET triggered!");
        noTone(BUZZER_PIN);
        alertTriggered = false;

        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("System Reset");
        lcd.setCursor(0, 1);
        lcd.print("Resuming...");
        delay(2000);
        lcd.clear();
      }
    }
  }

  if (reading == HIGH) {
    buttonPressed = false; // ready for next press
  }

  lastButtonState = reading;

  // Trigger alert if beam is broken
  if (ldrValue < LDR_THRESHOLD && !alertTriggered) {
    alertTriggered = true;

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("!!! ALERT !!!");
    lcd.setCursor(0, 1);
    lcd.print("INTRUDER ALERT");

    tone(BUZZER_PIN, 1000);
  }

  // Normal monitoring
  if (!alertTriggered) {
    lcd.setCursor(0, 0);
    lcd.print("Monitoring...   ");
    lcd.setCursor(0, 1);
    lcd.print("Beam Intact     ");
  }

  delay(50); // Small delay for readability
}

07 Code Breakdown

Here is what each part of the code does.

Library Used

Library Purpose
LiquidCrystal_I2C.h LiquidCrystal I2C library by Frank de Brabander, used to drive the 16x2 I2C LCD.

LDR (Light Dependent Resistor) Setup

#define LDR_PIN A0
#define LDR_THRESHOLD 600

  • LDR_PIN A0: Reads the laser status through the LDR.
  • LDR_THRESHOLD 600: If the LDR value drops below this threshold, it means the laser beam is broken.

Laser Setup

#define LASER_PIN 9

  • LASER_PIN 9: Activates the laser to form the tripwire.

Button Setup (for Reset)

#define BUTTON_PIN 7

  • BUTTON_PIN 7: Detects a button press to reset the system after an alert.

Button Debounce Logic

Arduino / C++
if ((millis() - lastDebounceTime) > DEBOUNCE_DELAY) {
  if (reading == LOW && !buttonPressed) {
    buttonPressed = true;
    if (alertTriggered) {
      noTone(BUZZER_PIN); // Stop buzzer
      alertTriggered = false; // Reset alert

      lcd.clear();
      lcd.print("System Reset");
      delay(2000); // Pause before resuming
      lcd.clear();
    }
  }
}
  • Button Debounce: Ensures stable button-press detection, and resets the alert when pressed.

Laser Beam Break (Intruder Detection)

Arduino / C++
if (ldrValue < LDR_THRESHOLD && !alertTriggered) {
  alertTriggered = true;
  tone(BUZZER_PIN, 1000); // Start buzzer
  lcd.clear();
  lcd.print("!!! ALERT !!!");
  lcd.print("INTRUDER ALERT");
}
  • Intruder Detection: If the laser beam is broken, it triggers an alert by sounding the buzzer and showing the message on the LCD.

Normal Monitoring

Arduino / C++
if (!alertTriggered) {
  lcd.setCursor(0, 0);
  lcd.print("Monitoring...");
  lcd.print("Beam Intact");
}
  • Normal Monitoring: If no alert is triggered (beam intact), the system displays "Monitoring..." on the LCD.

08 Testing and Calibration

  • Test the device by triggering the laser module so the LDR responds as well, confirm the buzzer turns on, and press the button to reset the device.
  • Adjust the code if necessary for compacting all the components into an enclosure box.

09 Final Adjustments

  • If the device is working properly, add the enclosure box for real-world deployment and for clean, tidy circuit and wire management.
  • Adjust LDR_THRESHOLD if too sensitive or not triggering.

10 Optional Tweaks

  • Make a PCB out of it for permanent and neat wiring for stable device performance.

11 System Demonstration

Video Demonstration

12 Conclusion

In conclusion, this Laser Tripwire project using the Arduino Uno, Laser Module, and LCD display offers a practical and interactive way to develop essential skills in microcontroller programming, sensor interfacing, and real-time alert systems. This project demonstrates how simple components like a laser and a light sensor can be combined with an LCD display to create an effective intrusion detection system. It provides valuable experience in building security-focused electronics, blending hardware and software to design a reliable and user-friendly solution. Through this project, you'll enhance your problem-solving abilities, gain a deeper understanding of embedded systems, and explore practical applications in home security and monitoring — making it an ideal introduction to IoT and smart security solutions.

13 References

  • Arduino Uno Official Guide
  • Laser Module & Light Sensor Tutorials
  • LCD I2C Display Integration with Arduino
  • Basic Security System Projects with Arduino

14 Project Authors

Authors (Capacitrio)

  • Mark A. Macahig
  • Knile Angelo B. Diez
  • Kent Lawrence M. Escobar
Quality Checked by
  • Lukie-Mar Lonzaga
  • Miles Darren Bagnol
  • Elijah Joseph Orias
Laser Tripwire Alarm System using Arduino Uno, Laser Module, and LDR Sensor – CreateLabz

 

Arduino uno, Battery, Battery holder 14500 with knife/switch, Buzzer, I2c lcd, Intruder detection system, Laser module, Ldr, Push button, Relay

Leave a comment

All comments are moderated before being published