Laser Tripwire Box with LCD Alert Using Arduino Uno

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.

Hardware Used

Software Use

  • Arduino IDE

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)

Pinout:

Arduino Laser Module: Connecting KY-008 to Arduino

The KY‑008 is a compact, low-cost red laser transmitter module which integrates a 650nm 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, it's ideal for simple laser pointer functions, optical communication, or creating laser tripwire setups. Handle with carenever point the laser at eyes or reflective surfaces.

Specifications:

Feature

Specification

Laser Wavelength

650nm (red beam)

Output Power

5mW (ClassIIIa/3A laser)

Operating Voltage

5V (some sources suggest 35V)

Operating Current

~30–40mA

Temperature Range

−10°C to +40°C

Module Size

~18.5×15mm (PCB); some list 15×24mm

Heat & Regulation

Simple resistor-based current limiting; may heat under long operation


    • LDR Light Sensor Module

    Uploaded image

    Pinout: 

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

     

    • Passive Buzzer Module 5V (FC – 07)

    Uploaded image

    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–5kHz typically) to produce sounds like tones or melodies. It doesn't buzz with steady DC voltageonly with oscillating signals.

     

    Key Specifications

    Feature

    Details

    Operating Voltage

    3.3–5V DC

    Rated Current

    <30mA typical

    Drive Signal Frequency

    PWM square‑wave, ~1.5–5kHz (resonant freq 2.5kHz)

    Sound Level

    85dB @10cm

    PCB Size

    ~20×20mm (some ~33×13×10mm)

    Weight

    ~3g

    Modules Includes

    Often includes LED indicator, S8550 driver transistor, and a 3‑pin cable

     

    • LCD Module 16x02 with i2C

    Uploaded image

    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.

     

    Hardware Setup

      Wiring Diagram:

      Procedure: Step-by-Step Build Guide

      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 your provided sketch.
      3. Make sure LiquidCrystal_I2C library is installed.
      4. Connect Arduino to 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 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 nonconductive adhesive to build the device with the enclosure provided.

       

      Optional Tweaks

      • Adjust LDR_THRESHOLD if too sensitive or not triggering.


      Software Setup

      • This is the Arduino sketch use for the project:
      #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 press
        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
      }


      Code Breakdown

        Library Used:

        • #include <LiquidCrystal_I2C.h> - We used the LiquidCrystal I2C by Frank de Brabander

        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 button press to reset the system after an alert.

        Button Debounce Logic:

        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):

        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:

        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.

        Testing and Calibration

        • Test the device by triggering the laser module so that the LDR will trigger as well and the buzzer will turn on and pressed the button for resetting the device.
        • Adjust the code if necessary for compacting all the components in an enclosure box.

        Final Adjustments

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

          Optional Tweaks

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

          Video Demonstration

          Conclusion

          In conclusion, this Laser Tripwire Box project using the Arduino Uno, Laser Module, and OLED 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 OLED 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.

          References

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

            Authors (Capacitrio)

              • Mark A. Macahig
              • Knile Angelo B. Diez
              • Kent Lawrence M. Escobar
              Arduino unoBatteryBattery holder 14500 with knife/switchBuzzerI2c lcdIntruder detection systemLaser moduleLdrPush buttonRelay

              Leave a comment

              All comments are moderated before being published