DIY Motion-Activated Relay Control using Arduino

Image
  Introduction Have you ever wanted to create a simple motion-activated project using Arduino? In this tutorial, we'll guide you through building a motion-activated relay control system using a Passive Infrared (PIR) sensor and an Arduino board. This project is perfect for beginners and provides a hands-on introduction to working with sensors and actuators. Components Needed Arduino board (e.g., Arduino Uno) Passive Infrared (PIR) sensor Relay module Jumper wires Breadboard Wiring the Components First, let's set up the hardware. Connect the PIR sensor and relay module to the Arduino as follows: PIR sensor: Connect the sensor's VCC pin to 5V on the Arduino. Connect the GND pin to GND on the Arduino. Connect the OUT pin to digital pin 5 on the Arduino. Relay module: Connect the VCC pin to 5V on the Arduino. Connect the GND pin to GND on the Arduino. Connect the IN or signal pin to digital pin 6 on the Arduino. Ensure that your connections are secure and double-check the speci

DIY Door Lock Security System with Arduino and Keypad: A Step-by-Step Guide



Introduction

Securing your home or workspace is a top priority, and with the power of Arduino, creating a custom door lock security system becomes an exciting and achievable project. In this guide, we'll explore how to build a Door Lock Security System using an Arduino Uno, a 4x4 Keypad, and a Servo Motor.

Components Needed

  1. Arduino Uno
  2. 4x4 Keypad
  3. Servo Motor
  4. Jumper Wires

Circuit Connections

  1. Connect the keypad to the Arduino Uno using jumper wires, ensuring correct connections for rows and columns.
  2. Connect the servo motor to the Arduino, with the signal wire to a digital pin, power wire to 5V, and ground wire to GND.

Code Explanation

The provided Arduino code uses the Keypad library to read input from the 4x4 keypad. A servo motor is employed to simulate a door lock mechanism. When the '#' key is pressed, it toggles the door lock state between locked and unlocked.

Note: It is essential to have the Keypad and Servo libraries installed in the Arduino IDE. Pin numbers and servo positions should be adjusted based on actual hardware connections.

Arduino Code:

// Include necessary libraries #include <Keypad.h> #include <Servo.h> // Define keypad layout const int ROWS = 4; const int COLS = 4; char keys[ROWS][COLS] = { {'1','2','3','A'}, {'4','5','6','B'}, {'7','8','9','C'}, {'*','0','#','D'} }; // Define keypad pin connections byte rowPins[ROWS] = {9, 8, 7, 6}; byte colPins[COLS] = {5, 4, 3, 2}; // Create Keypad and Servo objects Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS); Servo doorLock; // Define servo positions const int unlockPosition = 90; const int lockPosition = 0; bool doorLocked = true; // Initial door state void setup() { // Attach the servo to pin 10 doorLock.attach(10); Serial.begin(9600); } void loop() { char key = keypad.getKey(); if (key) { Serial.println(key); if (key == '#') { if (doorLocked) { unlockDoor(); } else { lockDoor(); } } } } void unlockDoor() { doorLock.write(unlockPosition); delay(1000); // Delay to ensure the servo has enough time to move doorLocked = false; Serial.println("Door Unlocked"); } void lockDoor() { doorLock.write(lockPosition); delay(1000); // Delay to ensure the servo has enough time to move doorLocked = true; Serial.println("Door Locked"); }

Additional Considerations

  1. Password Protection:

    • Enhance security by implementing a password system instead of a single '#' key press.
    • Utilize a secure algorithm for password validation.
  2. Multiple User Support:

    • Consider expanding the system to support multiple users with unique access codes.
  3. Encrypted Communication:

    • For advanced security, explore options for encrypted communication between the keypad and Arduino.

Conclusion

Congratulations! You've successfully created a DIY Door Lock Security System using Arduino and a keypad. As you explore further, consider additional security features and encryption methods to tailor the system to your specific needs.

Stay tuned for more exciting Arduino projects and security system guides in our DIY series!



Comments

Popular posts from this blog

Interfacing Ultrasonic Sensor, Relay Module, and 16x2 I2C LCD with Arduino

DIY Motion-Activated Relay Control using Arduino