RFID Project

RFID Sliding Door Lock Using Arduino|rfid project

Introduction

Hey guys, welcome back to Techatronic. In this article, we are going to discuss that how you can make your own RFID project sliding door lock using Arduino.

The messages will display on the 16×2 LCD screen. For controlling the movement of the motorized gate we are using an L298n motor driver module. You have to make the circuit first and then upload the given code to the Arduino. You can also check out more projects on Arduino and IoT.

HTML Image as link
Qries
rfid sliding door lock

Description

  • This system is useful for making the home or office security projects.
  • You are provided with smart cards to get access to the entrance.
  • You have to put the smart card on the reader module.
  • The system will automatically check for the correct card id and open the gate if the card id is matched with the data that we have provided earlier to the system.
  • If the id of the smart card matched with the id present in the database then the green LED will glow else the red LED will glow along with the ringing buzzer.
  • You can also check the windows login using RFID made by us.
rfid module
serial monitor
rfid sliding door lock
rfid sliding door lock

Components Required

  • Arduino UNO
  • RC522 RFID module
  • 16×2 LCD
  • 10K Potentiometer
  • 9 volts battery and a switch
  • L298n motor driver module
  • 220 ohm resistors
  • Jumper wires and a breadboard
  • Buzzer and two LEDs
rfid project component

Circuit for RFID rfid project Sliding Door Lock

rfid project circuit
Arduino UNORFID – RC522 Module 
10   PinSDA    Pin 
13   PinSCK     Pin 
11   PinMOSI  Pin 
12   PinMISO  Pin 
No  PinIRQ     Pin 
GNDGND 
9     PinRST      Pin 
3.3 V3.3 V 
Arduino UNOBuzzer 
6 PinPositive 
GNDNegative 
L293D ModuleMotor 
Terminal 1Terminal 1 
Terminal 2Terminal 2 
Arduino UNO16*2 LCD10K Potentiometer
GND VSS, K 
+5 VVDD, A 
GNDVSS (Ground)Terminal 1
 VEE ( Contrast )Terminal 2
+5 VVDD ( +5V )Terminal 3
A0 PinRS ( Register Select ) 
GNDRW ( Read\Write ) 
A1 PinE ( Enable ) 
A2 PinD4 
A3 PinD5 
A4 PinD6 
A5 PinD7 
Arduino UNOL298N Motor ModuleSwitchBattery
2 PinIN 1  
3 PinIN 2  
 12 VTerminal 1 
  Terminal 2Positive
GNDGND Negative
5 V5 V  
Arduino UNOLED 1LED 2220 Ohm Resistor
5 PinAnode Terminal  
7 Pin Anode Terminal 
GND  Terminal 1
 Cathode TerminalCathode TerminalTerminal 2

First of all, let us see the connections between the Arduino and RFID modules.

  • digital 10 pin -> SDA pin
  • digital 13 pin -> SCK pin
  • digital 11 pin -> MOSI pin
  • digital 12 pin -> MISO pin
  • GND pin -> GND pin
  • 3.3v pin -> 3.3v pin
  • digital 9 pin -> RST pin
  • Now connect the Arduino analog pins with the 16×2 LCD using a 10K potentiometer as shown in the circuit.
  • Join the positive leg of the red LED with the digital-7 pin of the Arduino.
  • Connect the positive leg of the green LED with the digital-5 pin of the Arduino.
  • Attach the negative legs of both of the LEDs to the GND pin via a 220 ohms resistor.
  • Take a buzzer and connect its positive leg with digital-6 pin of the Arduino and the negative leg with the GND pin of the Arduino.
  • Now connect digital-3 and digital-2 pins of the Arduino with the pins of the L298n motor driver.
  • Connect a dc motor to one pair of side pins of the driver module.
  • At last connect the terminals of the battery with the driver module and Arduino as shown above.
door rfid project
door rfid project

Code for RFID Sliding Door Lock

NOTE: Please upload the code given below to the Arduino. Before uploading you have to install <SPI.h>, <MFRC522.h>, and <LiquidCrystal.h> libraries to the Arduino IDE. Check here how to install zip libraries to the Arduino.

// TECHATRONIC.COM
// SPI Library
// https://github.com/PaulStoffregen/SPI
// MFRC522 Library
// https://github.com/miguelbalboa/rfid

#include <SPI.h>
#include <MFRC522.h>

#include "LiquidCrystal.h"
LiquidCrystal lcd (A0, A1, A2, A3, A4, A5);
 
#define SS_PIN 10
#define RST_PIN 9
#define LED_G 5   //define green LED pin D5
#define LED_R 7   //define red LED pin D7
#define BUZZER 6  //buzzer pin D+6
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
 
void setup() 
{
  Serial.begin(9600);       // Initiate a serial communication
  SPI.begin();              // Initiate  SPI bus
  lcd.begin(16,2);
  mfrc522.PCD_Init();       // Initiate MFRC522
 
  pinMode(LED_G, OUTPUT);
  pinMode(LED_R, OUTPUT);
  pinMode(BUZZER, OUTPUT);
  noTone(BUZZER);
  pinMode(3, OUTPUT);       // Motor pin
  pinMode(2, OUTPUT);       // Motor pin
  Serial.println("Put your card to the reader...");
  Serial.println();
  
  lcd.setCursor(0,0);
  lcd.print(" Put your card      ");

}
void loop() 
{
  // 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) == "7B 97 41 0C") //change here the UID of the card/cards that you want to give access
  {
    Serial.println("Authorized access");
    Serial.println();
       lcd.setCursor(0,0);
       lcd.print("  CARD IS VALID           ");
       lcd.setCursor(0,1);
       lcd.print("Opening the Door      ");
       digitalWrite(LED_G, HIGH);  //Green LED ON
       digitalWrite(LED_R, LOW);   // Red LED OFF
       digitalWrite(3, HIGH);      // Motor Clock Wise Clock  Direction
       digitalWrite(2, LOW);       // Motor Clock Wise Clock  Direction
 delay(2000);

       lcd.setCursor(0,1);
       lcd.print("closing the Door      ");
       digitalWrite(LED_G, LOW);   //Green LED OFF
       digitalWrite(LED_R, HIGH);  // Red LED ON
       digitalWrite(6, LOW);       // Motor Anti Clock Wise   Direction
       digitalWrite(7, HIGH);      // Motor Anti Clock Wise   Direction
 delay(2000);
       digitalWrite(6, LOW);       // Motor Stop
       digitalWrite(7, LOW);       // Motor Stop


       lcd.setCursor(0,0);
       lcd.print(" Put your card      ");
       lcd.setCursor(0,1);
       lcd.print("                            ");
  }
   
 else 
 {
    Serial.println("CARD IS INVALID");
      lcd.setCursor(0,1);
      lcd.print("CARD IS INVALID      ");
      digitalWrite(LED_G, LOW);       //Green LED OFF  
      digitalWrite(LED_R, HIGH);      // Red LED ON
      tone(BUZZER, 300);              // Buzzer ON
    
delay(1000);
      digitalWrite(LED_R, HIGH);      // Red LED ON
      noTone(BUZZER);                 // Buzzer OFF
      lcd.setCursor(0,1);
      lcd.print("                            ");
  }
}
rfid project

We hope that you liked this project and if you have any suggestions or doubts regarding this project then ping us in the comments section given below. Also, do check out more articles on Arduino and Raspberry Pi.

HTML Image as link
Qries

Thanks for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button