noneedforit
Published © LGPL

Arduino Security System

This Project Which Iam Sharing To You Is A Password Protected Lock System With Lcd Which Is Very Simple To Make So Lets Get Started

IntermediateFull instructions provided169
Arduino Security System

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Power Relay, SPDT
Power Relay, SPDT
×1
Adafruit keypad
×1
5 mm LED: Red
5 mm LED: Red
×1
I2C 16x2 Arduino LCD Display Module
DFRobot I2C 16x2 Arduino LCD Display Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1
5V 2.5A Switching Power Supply
Digilent 5V 2.5A Switching Power Supply
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver
Hot glue gun (generic)
Hot glue gun (generic)
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Story

Read more

Schematics

Schematics

Arduino Keypad Lock Circuit

Code

Arduino Code

C/C++
The Code For Keypad Lock System
//feel free to contact
//sreeramaj53@gmail.com
//www,youtube.com/ZenoModiff

#include <Wire.h>
#include <Keypad.h>                 
#include <LiquidCrystal_I2C.h>
#include<EEPROM.h>
LiquidCrystal_I2C liquid_crystal_display(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

char password[4];

char initial_password[4],new_password[4];

int i=0;

int Led_pin = 12;

char key_pressed=0;

const byte rows = 4; 
const byte columns = 4; 

char hexaKeys[rows][columns] = {

{'1','2','3','A'},

{'4','5','6','B'},

{'7','8','9','C'},

{'*','0','#','D'}

};

byte row_pins[rows] = {5,4,3,2};

byte column_pins[columns] = {6,7,8,9};   

Keypad keypad_key = Keypad( makeKeymap(hexaKeys), row_pins, column_pins, rows, columns);

byte locked[8] = { 
  B01110,
  B01010,
  B01010,
  B01010,
  B11111,
  B11111,
  B11111,
  B00000,
};
byte unlocked[8] = { 
  B01110,
  B01010,
  B00010,
  B00010,
  B11111,
  B11111,
  B11111,
  B00000,
};

byte key[8] = {
  B11111,
  B10001,
  B10001,
  B11111,
  B00100,
  B01100,
  B00100,
  B01100
};

void setup()

{

  pinMode(Led_pin, OUTPUT);

  liquid_crystal_display.begin(16,2);
  liquid_crystal_display.createChar(0, locked);
  liquid_crystal_display.createChar(1, unlocked);
  liquid_crystal_display.createChar(2, key);

  liquid_crystal_display.setCursor(1,0);

  liquid_crystal_display.print("  ZenoModiff");

  liquid_crystal_display.setCursor(0,1);

  liquid_crystal_display.write(byte(2));
  
  liquid_crystal_display.print(" Arduino Lock ");

  liquid_crystal_display.write(byte(2));

  delay(2000);

  liquid_crystal_display.clear();

  liquid_crystal_display.print(" Enter Password");

  liquid_crystal_display.setCursor(0,1);

  initialpassword();

}




void loop()

{

  digitalWrite(Led_pin, LOW);

  key_pressed = keypad_key.getKey();

  if(key_pressed=='#')

    change();

  if (key_pressed)

  {

    password[i++]=key_pressed;

    liquid_crystal_display.print(key_pressed);

      }

  if(i==4)

  {

    delay(200);

    for(int j=0;j<4;j++)

      initial_password[j]=EEPROM.read(j);

    if(!(strncmp(password, initial_password,4)))

    {

      liquid_crystal_display.clear();

      liquid_crystal_display.print(" Pass Accepted");

      liquid_crystal_display.setCursor(7,1);

      liquid_crystal_display.write(byte(1));

     
      digitalWrite(Led_pin, HIGH);

      delay(2000);

      liquid_crystal_display.clear();

      liquid_crystal_display.setCursor(0,1);

      liquid_crystal_display.print("Pres # to change");

      delay(2000);

      liquid_crystal_display.clear();

      liquid_crystal_display.print(" Enter Password:");

      liquid_crystal_display.setCursor(0,1);

      i=0;




    }

    else

    {

      digitalWrite(Led_pin, LOW);




      liquid_crystal_display.clear();

      liquid_crystal_display.print(" Wrong Password");

      liquid_crystal_display.setCursor(7,1);

      liquid_crystal_display.write(byte(0));
      
      delay(2000);

      liquid_crystal_display.clear();

      liquid_crystal_display.setCursor(0,1);

      liquid_crystal_display.print("Pres # to change");

      delay(2000);

      liquid_crystal_display.clear();

      liquid_crystal_display.print(" Enter Password:");

      liquid_crystal_display.setCursor(0,1);

      i=0;





    }

  }

}

void change()

{

  int j=0;

  liquid_crystal_display.clear();

  liquid_crystal_display.print("Current Password");

  liquid_crystal_display.setCursor(0,1);

  while(j<4)

  {

    char key=keypad_key.getKey();

    if(key)

    {

      new_password[j++]=key;

      liquid_crystal_display.print(key);

       

    }

    key=0;

  }

  delay(500);




  if((strncmp(new_password, initial_password, 4)))

  {

    liquid_crystal_display.clear();

    liquid_crystal_display.print("Wrong Password");

    liquid_crystal_display.setCursor(0,1);

    liquid_crystal_display.print("Try Again");

    delay(1000);

  }

  else

  {

    j=0;

    liquid_crystal_display.clear();

    liquid_crystal_display.print("New Password:");

    liquid_crystal_display.setCursor(0,1);

    while(j<4)

    {

      char key=keypad_key.getKey();

      if(key)

      {

        initial_password[j]=key;

        liquid_crystal_display.print(key);

        EEPROM.write(j,key);

        j++;

     

      }

    }

    liquid_crystal_display.print("Pass Changed");

    delay(1000);

  }

  liquid_crystal_display.clear();

  liquid_crystal_display.print("Enter Password");

  liquid_crystal_display.setCursor(0,1);

  key_pressed=0;

}




void initialpassword(){

  for(int j=0;j<4;j++)

    EEPROM.write(j, j+49);

  for(int j=0;j<4;j++)

    initial_password[j]=EEPROM.read(j);

}


 //    Coded With <3 ZenoModiff 
 //    sreeramzeno@gmail.com
 //    www.youtube.com/ZenoModiff

Credits

noneedforit

noneedforit

2 projects • 2 followers

Comments