Laser Security System
Laser Security System Using Arduino
This project creates a laser-based security system that triggers an audible and visual alarm when the laser beam is interrupted. The system uses a laser module and LDR sensor to detect intrusions, with a buzzer and LED providing immediate feedback. The alarm features a distinctive "tuuuuu tuuuuu" pattern that lasts for 5 seconds when triggered.

.png)
.png)
How the System Works
- Laser Module emits a continuous beam of light directed at the LDR sensor
- LDR (Light Dependent Resistor) detects the laser beam and maintains system in standby mode
- When the beam is interrupted: System triggers a 5-second alarm cycle
- Buzzer sounds with a distinctive "tuuuuu tuuuuu" pattern (700ms on, 300ms off)
- LED flashes in sync with the buzzer for visual indication
- After 5 seconds: System checks if laser beam is restored
- If beam remains interrupted: Another 5-second alarm cycle begins
- If beam is restored: System returns to standby monitoring mode
- 7.4V battery powers the entire system for portable operation
Materials Required
- Laser Module - Buy Here
- LDR Module - Buy Here
- Jumper Wires - Buy Here
- 5V Buzzer - Buy Here
- Red LED - Buy Here
- 220 Ohm Resistor - Buy Here
- Arduino Uno - Buy Here
- 7.4V Battery - Buy Here
- Square Mirrors - Buy Here
3D Model Files & Housing Design
Download the 3D printable files for the laser security system housing and components:
Download 3D Models House Design DiagramPrint these files using JLCPCB's 3D printing service:
Order 3D Parts Here🎥 Watch the video above for complete demonstration of the laser security system in action.
Arduino Code
Upload this code to your Arduino after completing all hardware connections:
// Laser Security System with 5-Second Synced "Tuuuuu" Pattern // Define pin connections const int LDR_VCC = 8; // LDR VCC connected to pin 8 const int LDR_GND = 9; // LDR GND connected to pin 9 const int LDR_DO = 10; // LDR Digital Output connected to pin 10 const int LASER_GND = 11; // Laser GND connected to pin 11 const int LASER_VCC = 12; // Laser VCC connected to pin 12 const int LASER_SIGNAL = 13; // Laser signal connected to pin 13 const int BUZZER_GND = A0; // Buzzer GND connected to pin A0 const int BUZZER_VCC = A3; // Buzzer VCC connected to pin A3 const int LED_GND = A5; // LED GND connected to pin A5 const int LED_VCC = A4; // LED VCC connected to pin A4 // Variables enum SystemState { NORMAL, ALARM_ACTIVE, ALARM_COMPLETED }; SystemState currentState = NORMAL; unsigned long alarmStartTime = 0; const unsigned long ALARM_DURATION = 5000; // 5 seconds in milliseconds // Siren pattern variables - optimized for 5-second cycles unsigned long lastSirenTime = 0; bool sirenOn = false; const unsigned long SIREN_ON_TIME = 700; // "Tuuuuu" duration (700ms) const unsigned long SIREN_OFF_TIME = 300; // Pause between "Tuuuuu" (300ms) void setup() { // Initialize pins pinMode(LDR_VCC, OUTPUT); pinMode(LDR_GND, OUTPUT); pinMode(LDR_DO, INPUT); pinMode(LASER_GND, OUTPUT); pinMode(LASER_VCC, OUTPUT); pinMode(LASER_SIGNAL, OUTPUT); pinMode(BUZZER_GND, OUTPUT); pinMode(BUZZER_VCC, OUTPUT); pinMode(LED_GND, OUTPUT); pinMode(LED_VCC, OUTPUT); // Set power pins correctly digitalWrite(LDR_VCC, HIGH); // Provide 5V to LDR digitalWrite(LDR_GND, LOW); // Provide GND to LDR digitalWrite(LASER_GND, LOW); // Provide GND to laser digitalWrite(LASER_VCC, HIGH); // Provide 5V to laser digitalWrite(LASER_SIGNAL, HIGH); // Turn on laser digitalWrite(BUZZER_GND, LOW); // Provide GND to buzzer digitalWrite(BUZZER_VCC, LOW); // Start with buzzer off digitalWrite(LED_GND, LOW); // Provide GND to LED digitalWrite(LED_VCC, LOW); // Start with LED off Serial.begin(9600); // For debugging Serial.println("Laser Security System Started"); Serial.println("System is ACTIVE"); } void updateSirenPattern() { unsigned long currentTime = millis(); unsigned long timeInAlarm = currentTime - alarmStartTime; unsigned long timeLeft = ALARM_DURATION - timeInAlarm; // Ensure we end with the buzzer OFF for a clean transition if (timeLeft < 100) { // Last 100ms of alarm period digitalWrite(LED_VCC, LOW); digitalWrite(BUZZER_VCC, LOW); return; } if (sirenOn) { // Currently in "Tuuuuu" ON phase if (currentTime - lastSirenTime >= SIREN_ON_TIME) { // "Tuuuuu" completed, switch to OFF phase sirenOn = false; lastSirenTime = currentTime; digitalWrite(LED_VCC, LOW); digitalWrite(BUZZER_VCC, LOW); } } else { // Currently in pause between "Tuuuuu" phases if (currentTime - lastSirenTime >= SIREN_OFF_TIME) { // Don't start a new "Tuuuuu" if there's not enough time to complete it if (timeLeft > SIREN_ON_TIME + 100) { sirenOn = true; lastSirenTime = currentTime; digitalWrite(LED_VCC, HIGH); digitalWrite(BUZZER_VCC, HIGH); } } } } void loop() { // Read LDR sensor int ldrValue = digitalRead(LDR_DO); // State machine switch (currentState) { case NORMAL: // Check if laser beam is broken (LDR not receiving light) if (ldrValue == HIGH) { // Trigger the alarm currentState = ALARM_ACTIVE; alarmStartTime = millis(); lastSirenTime = millis(); sirenOn = true; // Start with "Tuuuuu" ON digitalWrite(LED_VCC, HIGH); digitalWrite(BUZZER_VCC, HIGH); Serial.println("ALARM! Laser beam broken! Starting 5-second alarm."); } break; case ALARM_ACTIVE: // Update "tuuuuu tuuuuu" siren pattern (synchronized with 5-second cycle) updateSirenPattern(); // Check if 5 seconds have passed if (millis() - alarmStartTime >= ALARM_DURATION) { // 5 seconds completed, move to next state currentState = ALARM_COMPLETED; digitalWrite(LED_VCC, LOW); digitalWrite(BUZZER_VCC, LOW); Serial.println("5-second alarm completed. Checking laser status."); } break; case ALARM_COMPLETED: // Check if laser is back on LDR if (ldrValue == LOW) { // Laser is detected // Laser is restored, return to normal state currentState = NORMAL; Serial.println("Laser restored. System NORMAL"); } else { // Laser is still broken, trigger another alarm cycle currentState = ALARM_ACTIVE; alarmStartTime = millis(); lastSirenTime = millis(); sirenOn = true; // Start with "Tuuuuu" ON digitalWrite(LED_VCC, HIGH); digitalWrite(BUZZER_VCC, HIGH); Serial.println("Laser still broken! Starting another 5-second alarm."); } break; } // Small delay for stability delay(10); }
Code Explanation:
Setup:
Initializes all pin connections, sets up the laser module, LDR sensor, buzzer, and LED. Configures the system to start in monitoring mode.
Main Loop:
Continuously monitors the LDR sensor. When the laser beam is interrupted, triggers a 5-second alarm with the distinctive "tuuuuu tuuuuu" pattern. After 5 seconds, checks if the beam is restored and either returns to normal monitoring or starts another alarm cycle.
Step-by-Step Assembly
1. Circuit Connections:
- Connect LDR module: VCC→pin 8, GND→pin 9, DO→pin 10
- Connect laser module: GND→pin 11, VCC→pin 12, Signal→pin 13
- Connect buzzer: GND→pin A0, VCC→pin A3
- Connect LED: GND→pin A5, VCC→pin A4 (with 220Ω resistor)
- Connect 7.4V battery to power the system
2. Component Placement:
- Position the laser module and LDR sensor opposite each other
- Use mirrors to create a laser beam path for larger coverage areas
- Mount the buzzer and LED in visible locations for alarm indication
- Ensure all components are securely connected and insulated
3. System Testing:
- Upload the Arduino code to your board
- Power on the system and verify the laser activates
- Check that the LDR detects the laser beam (system in normal mode)
- Interrupt the beam to test the alarm activation
- Verify the 5-second alarm pattern with buzzer and LED
Why Choose This Design?
- ✅ Effective Intrusion Detection: Laser-based system provides reliable security monitoring
- ⚡ Distinctive Alarm Pattern: "Tuuuuu tuuuuu" sound pattern is attention-grabbing
- 🔄 Self-Resetting: Automatically returns to monitoring after alarm cycle
- 💡 Visual Indicator: LED provides visual confirmation of alarm state
- 🛠️ Expandable: Can be extended with multiple lasers for larger areas
- 🔋 Portable: Battery-powered for flexible placement
Advanced Applications
- Add multiple laser/LDR pairs for zone-based security coverage
- Integrate with home automation systems for remote notifications
- Add a keypad for arming/disarming the system
- Incorporate wireless communication for remote monitoring
- Use mirrors to create complex laser maze security systems
Comments
Post a Comment