Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!

GaurdX

A smart lock is an advanced security system that allows users to unlock doors either by entering PINS using KEYPAD or via BLUETOOTH

BeginnerFull instructions provided3 hours495
GaurdX

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
The microcontroller board that controls the system
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
LCD Screen used to display the Access Granted and Denied
×1
Grove - 12-Channel Capacitive Touch Keypad (ATtiny1616)
Seeed Studio Grove - 12-Channel Capacitive Touch Keypad (ATtiny1616)
Matrix Keypad to enter the pin of the lock
×1
4-CHANNEL RELAY CONTROLLER FOR I2C
ControlEverything.com 4-CHANNEL RELAY CONTROLLER FOR I2C
5 Volt Relay to open and close circuits to control electrical loads
×1
LOCK
Used as a lock in the connections
×1
Jumper wires (generic)
Jumper wires (generic)
Used for all electrical connections
×1

Software apps and online services

Arduino IDE
Arduino IDE
The integrated Development Environment used for writing and uploading the Arduino code
Tinkercad
Autodesk Tinkercad
Onlin platform for designing and simulating circuits, allowing you to visualize and test your project virtually
Serial Bluetooth Terminal

Story

Read more

Code

GaurdX Code

C/C++
#include <Key.h>
#include <Keypad.h>
#include <SoftwareSerial.h>

#include <LiquidCrystal.h>
const char predefinedPassword[4] = "*911";
const int passwordLength = 4;
int inputLength = 5;

char val[5];

char inputPassword[passwordLength + 1];
int inputCount = 0 ; //Counter for input from keypad

const byte ROWS = 4 ; //Number of rows on keypad
const byte COLS = 3 ; //Number of columns on keypad 

char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

byte rowPins[ROWS] = {2,3,4,5}; // ROWS PINS ON ARDUINO
byte colPins [COLS] = {6,7,8}; // COLUMN PINS ON ARDUINO

Keypad keypad = Keypad(makeKeymap(keys), rowPins , colPins , ROWS , COLS );
LiquidCrystal lcd(A5,13,A3,A1,A4,A2); // RS,E,D4,D5,D6,D7
SoftwareSerial bt(12,11); //12 for RX and 11 for TX

void setup(){
  char key = keypad.getKey();

  if(bt.available()>0)
  {
    bt.readBytesUntil('\0', inputPassword , 4);
    val[4]='\0';
    checkPass();
/*
  if (strcmp(val.predefinedPassword)==0)
  {
    lcd.clear();
    lcd.print("Access Granted");
    Serial.println(val);
  }
  else
  {
    Serial.print("Hi");
    lcd.clear();
    Serial.print(val);
    lcd.print("Acess Denied");
    Serial.println(inputPassword);
    delay(2000);
    lcd.clear();
    lcd.print("Enter Password : ");
  }*/
  }
  if (key){
    lcd.setCursor(inputCount,1);
    lcd.print("*");
    //stor the key press in the inputPassword array
    if (inputCount < passwordLength){
      inputPassword[inputCount] = key;
      inputCount++ ;
      //lcd.print(key);
    }
    if (inputCount == passwordLength){
      inputPassword[inputLength] = '\0';
      checkPass();
      inputCount = 0;
    }
  }
}

void checkPass()
{
  if(strcmp(inputPassword , predefinedPassword)==0){
    lcd.clear();
    lcd.print("Acess Granted");
    digitalWrite(10,0);
    Serial.println(inputPassword);
  }
  else{
    lcd.clear();
    lcd.print("Access Denied");
    Serial.println(inputPassword);
  }

  delay(4000);
  lcd.clear();
  lcd.print("Enter Password : ");
  digitalWrite(10,1);
}

Credits

Prince Singh
2 projects • 2 followers
Contact
Harsh Parashar
2 projects • 3 followers
Contact
Vikas Sharma
4 projects • 6 followers
Contact
Dr. Umesh Dutta
42 projects • 60 followers
Working as Director of Innovation Centre at Manav Rachna, India. I am into development for the last 12 years.
Contact

Comments

Please log in or sign up to comment.