Projects / Laser tripwire alarm

Laser tripwire alarm

Beginner1 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. NANO

    Check the laser and aim

    Power the laser. Never look into the beam or aim it at eye height or at windows.

  2. NANO865 lux

    Mount the LDR

    Put the LDR in a short black tube pointing at the laser, so room light does not matter.

  3. NANO866 lux

    Aim across the doorway

    Put the laser at waist height, and tape the LDR and tube opposite.

  4. NANO866 lux

    Build the divider

    LDR and 10 kΩ to A0 as in the table.

  5. NANO

    Upload and wait

    The sketch waits 10 s, then measures the beam level.

  6. NANO

    Test

    Wave a hand through the beam. The buzzer pulses until you press the hidden reset button.

In short

How do you build a laser tripwire alarm?

A laser pointer module shines across a doorway onto an LDR, and the alarm sounds when anyone breaks the beam. You need Arduino Nano, Laser diode module 5 V (red, 650 nm), LDR Photoresistor, Resistor 10 kΩ, Active buzzer 5 V, Tactile push button 6 mm, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm) and 5 V 2 A USB adapter. It takes 6 steps and about 60 minutes.

Level
Beginner
Time
About 60 min
Parts
9

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Laser module + and GNDNano 5V and GNDAlways on (check your module's pin markings)
LDRNano 5V and A0, with 10 kΩ from A0 to GNDBeam detector, brighter means higher
Buzzer +Nano D8Alarm
Buzzer -Nano GNDReturn
Reset buttonNano D2 and GNDHidden button

Code

Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). No libraries. The 10 second delay at start lets you aim the laser and leave. Take care that the baseline is read with the beam on the LDR.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

const byte LDR = A0, BUZZ = 8, RESET_BTN = 2;
int baseline = 0;
bool alarm = false;
unsigned long brokeAt = 0;

void setup() {
  pinMode(BUZZ, OUTPUT);
  pinMode(RESET_BTN, INPUT_PULLUP);
  delay(10000);                                   // time to leave the room
  long sum = 0;
  for (byte i = 0; i < 20; i++) { sum += analogRead(LDR); delay(50); }
  baseline = sum / 20;                            // reading with the beam on the LDR
}

void loop() {
  int v = analogRead(LDR);
  bool broken = v < baseline * 6 / 10;            // below 60 percent of the beam level
  if (broken) {
    if (brokeAt == 0) brokeAt = millis();
    if (millis() - brokeAt > 50) alarm = true;    // ignore flickers shorter than 50 ms
  } else brokeAt = 0;

  if (alarm) {
    digitalWrite(BUZZ, (millis() / 200) % 2);     // pulsing buzzer
    if (digitalRead(RESET_BTN) == LOW) { alarm = false; digitalWrite(BUZZ, LOW); delay(10000); }
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Beam on LDRA0 reads high and steady
Hand through the beamBuzzer starts at once
Room light turned onNo false alarm because the tube shades the LDR
Reset buttonBuzzer stops and re-arms after 10 seconds

If it does not work

Alarm on at start

The laser is not hitting the LDR when the baseline is read. Align it again.

No alarm when the beam is broken

Room light gets in the tube, so the LDR barely changes. Lengthen the tube.

Laser is dim

Check supply and polarity, and that the module is a 5 V type.

Random alarms

The laser or LDR moved. Fix them to rigid supports.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the laser tripwire alarm?

Arduino Nano, Laser diode module 5 V (red, 650 nm), LDR Photoresistor, Resistor 10 kΩ, Active buzzer 5 V, Tactile push button 6 mm, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm) and 5 V 2 A USB adapter.

How long does the laser tripwire alarm take to build?

About 60 minutes for a beginner maker, in 6 steps.

How do I know the laser tripwire alarm works?

Beam on LDR: A0 reads high and steady. Hand through the beam: Buzzer starts at once. Room light turned on: No false alarm because the tube shades the LDR.

Alarm on at start: what should I check?

The laser is not hitting the LDR when the baseline is read. Align it again.

No alarm when the beam is broken: what should I check?

Room light gets in the tube, so the LDR barely changes. Lengthen the tube.

Laser is dim: what should I check?

Check supply and polarity, and that the module is a 5 V type.

Random alarms: what should I check?

The laser or LDR moved. Fix them to rigid supports.