technoesolution
Published © CC BY-NC-SA

RFID Based Door Lock System Using Arduino Uno

Here I'll explain to you How to make RFID based door lock system using Arduino in a simple way.

IntermediateFull instructions provided15,341
RFID Based Door Lock System Using Arduino Uno

Things used in this project

Hardware components

Arduino Uno
×1
RFID Module (RC522)
×1
I2C LCD Display
×1
1-Channel Relay Module
×1
Solenoid Lock
×1
Push-button
×1
Jumper Wires
×1
Resistor (1k)
×1
Resistor (470E/330E)
×1
LM2596 Module
×1
LED
×1
12V Adapter
×1
Breadboard
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit Diagram

Code

Arduino Code.

C/C++
/*
 * Hello,Welcome TO Techno-E-Solution
 * Check out Video Tutorial of this project:- https://www.youtube.com/watch?v=mmF7q6Nuj6Y
 * Here is the Arduino Code for "RFID Based Door Lock System Using Arduino"
 */
#include <Wire.h>
#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal_I2C.h> 
LiquidCrystal_I2C lcd(0x27, 16, 2);
 
#define SS_PIN 10
#define RST_PIN 9
#define LED_G 4 // Green LED pin
#define LED_R 5 // Red LED pin
#define lock 3

MFRC522 mfrc522(SS_PIN, RST_PIN);
int Btn = 6;
 
void setup() 
{
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();
  pinMode(LED_G, OUTPUT);
  pinMode(LED_R, OUTPUT);
  pinMode(Btn,INPUT);
  pinMode(lock,OUTPUT);
  Serial.println("Place your card on reader...");
  Serial.println();
  lcd.init();
  lcd.backlight();
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(" Scan Your RFID "); 
  lcd.setCursor(0,1);
  lcd.print("   Door Locked   ");

 }
void loop() 
{

if(digitalRead(Btn) == HIGH){
  
    Serial.println("Access Granted");
    Serial.println();
    delay(500);
    digitalWrite(LED_G, HIGH);
    lcd.setCursor(0,1);
    lcd.print(" Door Un-Locked ");
    digitalWrite(lock,HIGH);
    delay(3000);
    digitalWrite(lock,LOW);
    delay(100);
    digitalWrite(LED_G, LOW);
    lcd.setCursor(0,1);
    lcd.print("   Door Locked   ");
  }


  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();


  
 if (content.substring(1) == "6A 7F 65 B3") //change here the UID of card/cards or tag/tags that you want to give access
  {
    Serial.println("Access Granted");
    Serial.println();
    delay(500);
    digitalWrite(LED_G, HIGH);
    lcd.setCursor(0,1);
    lcd.print(" Door Un-Locked ");
    digitalWrite(lock,HIGH);
    delay(3000);
    digitalWrite(lock,LOW);
    delay(100);
    digitalWrite(LED_G, LOW);
    lcd.setCursor(0,1);
    lcd.print("   Door Locked   ");
  }

else
{
    lcd.setCursor(0,1);
    lcd.print("Invalid RFID Tag");
    Serial.println(" Access denied");
    digitalWrite(LED_R, HIGH);
    digitalWrite(LED_R, LOW);
    delay(100);
    digitalWrite(LED_R, HIGH);
    delay(500);
    digitalWrite(LED_R, LOW);
    delay(100);
    digitalWrite(LED_R, HIGH);
    delay(500);
    digitalWrite(LED_R, LOW);
    lcd.setCursor(0,1);
    lcd.print("   Door Locked   ");
 }
 delay (100);
 }

Credits

technoesolution

technoesolution

23 projects • 15 followers
Youtuber | Electrical Engineer | Electronics Lover | Article Writer | Project Developer |

Comments