{"id":24811950,"url":"https://github.com/arrajkamel/motiondetectionsecuritysystem","last_synced_at":"2026-05-01T10:32:17.519Z","repository":{"id":271799133,"uuid":"914596906","full_name":"ArrajKamel/MotionDetectionSecuritySystem","owner":"ArrajKamel","description":"An Arduino-based motion detection security system with password protection, FSM-driven behavior, and modular design for home automation and IoT applications.","archived":false,"fork":false,"pushed_at":"2025-03-03T19:23:16.000Z","size":747,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T14:29:42.578Z","etag":null,"topics":["arduino","cpp","infrared-sensor","motion-sensor"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ArrajKamel.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-09T22:59:22.000Z","updated_at":"2025-03-03T19:23:19.000Z","dependencies_parsed_at":"2025-03-03T20:22:50.393Z","dependency_job_id":"6e0fc747-7acb-4ea9-81ad-5e21f5688635","html_url":"https://github.com/ArrajKamel/MotionDetectionSecuritySystem","commit_stats":null,"previous_names":["arrajkamel/motiondetectionsecuritysystem"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ArrajKamel/MotionDetectionSecuritySystem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArrajKamel%2FMotionDetectionSecuritySystem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArrajKamel%2FMotionDetectionSecuritySystem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArrajKamel%2FMotionDetectionSecuritySystem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArrajKamel%2FMotionDetectionSecuritySystem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ArrajKamel","download_url":"https://codeload.github.com/ArrajKamel/MotionDetectionSecuritySystem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArrajKamel%2FMotionDetectionSecuritySystem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32494270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","cpp","infrared-sensor","motion-sensor"],"created_at":"2025-01-30T13:17:00.062Z","updated_at":"2026-05-01T10:32:17.466Z","avatar_url":"https://github.com/ArrajKamel.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔐 Motion Detection Security System\n\n## 📜 Overview  \nThe **Motion Detection Security System** is an Arduino-based project designed to provide a robust and reliable security solution. It leverages a Sharp infrared sensor for motion detection, a 4x4 keypad for password authentication, and a Finite State Machine (FSM) to manage the system's behavior. The project is modular and scalable, making it suitable for real-world applications like home automation, and IoT security.\n\n---\n\n## 🎯 Features  \n\n- **Motion Detection**: Utilizes the Sharp 2D120x infrared sensor to detect motion within a defined range.  \n- **Password Protection**: A 4x4 keypad is used to enter and verify passwords, ensuring secure access to critical states like sleep mode.  \n- **Finite State Machine (FSM)**: Clearly defined states (`IDLE`, `TIMER_ON`, `ALARM_ACTIV`, and `SLEEP`) for structured and predictable behavior.  \n- **Alarm System**: Activates a red LED and buzzer after a defined timeout period when motion is detected but not resolved.  \n- **Sleep Mode**: Disables motion detection and alarms, conserving energy until manually reactivated.  \n- **Energy Efficiency**: The system supports toggling to sleep mode, which disables unnecessary hardware until required.  \n\n---\n\n## 🔧 Hardware Components  \n\n### Required Components  \n1. **Arduino Mega**  \n2. **Sharp 2D120x Infrared Distance Sensor**  \n3. **4x4 Keypad**  \n4. **16x2 LCD**  \n5. **Buzzer**  \n6. **Red LED**  \n7. **Push Button (Activation Toggle)**  \n\n### Hardware Connections  \n1. **Sharp Sensor**:  \n   - Signal pin → `A15`  \n   - VCC → `5v`  \n   - Ground → `GND`  \n\n2. **4x4 Keypad**:  \n   - Row pins → Digital pins `{A0, A1, A2, A3}`  \n   - Column pins → Digital pins `{A4, A5, A7, A8}`  \n\n3. **LCD with I2C**:\n   - LCD shield is used. \n\n5. **Buzzer and LED**:  \n   - Buzzer pin → `25`  \n   - LED pin → `26`  \n\n6. **Activation Button**:  \n   - One side → `33`  \n   - Ground → `GND`\n\n## Schema \n\n![schema](resources/schema.png)\n### note \n   - consider the Sharp Sensor instead of the Ultrasonic Distance Sensor.\n\n\n---\n\n## ⚙️ System States  \n\nThe system is governed by a Finite State Machine with the following states:  \n\n1. **IDLE**:  \n   - The system scans for motion using the Sharp sensor.  \n   - Transitions to `TIMER_ON` on motion detection or stays in `IDLE` if no motion is detected.  \n\n2. **TIMER_ON**:  \n   - A timer is activated when motion is detected.  \n   - The system transitions to `ALARM_ACTIV` on timeout, to `SLEEP` if the correct password is entered, or back to `IDLE` if motion ceases.  \n\n3. **ALARM_ACTIV**:  \n   - The system activates a buzzer and LED.  \n   - Transitions to `SLEEP` on correct password entry or to `IDLE` after the alarm auto-stops.  \n\n4. **SLEEP**:  \n   - The system disables motion detection and alarms.  \n   - Transitions back to `IDLE` upon pressing the activation button.\n\n## 📊 FSM Diagram\n\n![FSM Diagram](resources/FSMDiagram.png)\n\n\n---\n\n### 🚀 Real-World Applications  \n\nThis project can be applied to various domains, such as:  \n\n1. **Home Security**: Detect motion and secure the premises with alarms and authentication.  \n2. **IoT Devices**: Integrate with smart home systems for advanced automation.  \n3. **Industrial Monitoring**: Use the system to monitor unauthorized access in factories or warehouses.  \n\n---\n\n### 📈 Future Improvements  \n\n1. **WiFi Integration**: Add ESP32 capabilities to send notifications to a mobile app or email.  \n2. **Battery Optimization**: Implement low-power modes for energy-efficient operation.  \n3. **Camera Integration**: Add a camera module for capturing images upon motion detection.\n\n---\n\n## 🖥️ Software Implementation  \n\n### Libraries Used  \n1. `LiquidCrystal.h`: For interfacing with the LCD.  \n2. `Keypad.h`: For handling input from the 4x4 keypad.  \n\n### FSM Implementation  \nThe FSM is implemented using an `enum` to define the states, with transitions handled in a `switch-case` structure. Each state has its own function to manage behavior and transitions.\n\n### Key Functions  \n\n1. **Motion Detection**  \n```cpp\nvoid checkMotion() {\n  int sharpValue = analogRead(SHARP_SENSOR_PIN);\n  motionDetected = (sharpValue \u003e 300 \u0026\u0026 sharpValue \u003c 700); // Adjust range\n\n  if (motionDetected) {\n    currentState = TIMER_ON;\n    timerStartTime = millis();\n    lcd.clear();\n    lcd.print(\"Motion Detected\");\n  }\n}\n```\n2. **Password Verification**  \n```cpp\nvoid handleKeypadInput() {\n  char key = keypad.getKey();\n  if (key) {\n    enteredPassword += key;\n    lcd.setCursor(0, 1);\n    lcd.print(enteredPassword);\n\n    if (enteredPassword.length() == correctPassword.length()) {\n      if (enteredPassword == correctPassword) {\n        currentState = SLEEP;\n        enterSleepMode();\n      } else {\n        lcd.print(\"Wrong Password\");\n        delay(2000);\n        enteredPassword = \"\";\n      }\n    }\n  }\n}\n```\n\n3. **Sleep Mode Activation**\n```cpp\nvoid enterSleepMode() {\n  lcd.clear();\n  lcd.print(\"Entering Sleep\");\n  delay(2000);\n  lcd.clear();\n  lcd.print(\"System in Sleep\");\n}\n```\n\n4. **Activation Button Handling**\n```cpp\nvoid handleActivationButton() {\n  if (digitalRead(ACTIVATION_BUTTON) == LOW) {\n    lcd.clear();\n    lcd.print(\"Reactivating...\");\n    delay(5000); // Simulate delay\n    currentState = IDLE;\n    lcd.clear();\n    lcd.print(\"System Ready\");\n  }\n}\n```\n\n---\n\n## 📫 Let’s Collaborate\nFeel free to fork this repository or submit a pull request to improve or expand this project. Let’s build something great together!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farrajkamel%2Fmotiondetectionsecuritysystem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farrajkamel%2Fmotiondetectionsecuritysystem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farrajkamel%2Fmotiondetectionsecuritysystem/lists"}