How to make an RFID door lock with Arduino


 



Welcome to our DIY RFID Door Lock with Arduino tutorial! In this video, we'll guide you through the process of building your own RFID-based door lock system for added security to your home or workspace. With just a few components and some basic coding, you can create a reliable access control system.


Circuit:-

coding         

//TECHNO SAP
//RFID Door Lock System

#include <Wire.h>
#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal_I2C.h> 
LiquidCrystal_I2C lcd(0x3F, 16, 2);
 
#define SS_PIN 10
#define RST_PIN 9
#define LED_G 4 //define green LED pin
#define LED_R 5 //define red LED
#define BUZZER 2 //buzzer pin
#define lock 3
#define MOTOR_FORWARD 7 // L298N motor driver control pins
#define MOTOR_BACKWARD 8
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
int Btn = 6;
 
void setup() 
{
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  pinMode(LED_G, OUTPUT);
  pinMode(LED_R, OUTPUT);
  pinMode(BUZZER, OUTPUT);
  pinMode(MOTOR_FORWARD, OUTPUT); // Motor control pins
  pinMode(MOTOR_BACKWARD, OUTPUT);
  digitalWrite(MOTOR_FORWARD, LOW); // Motor off initially
  digitalWrite(MOTOR_BACKWARD, LOW);
  noTone(BUZZER);
  pinMode(Btn,INPUT);
  pinMode(lock,OUTPUT);
  Serial.println("Place your card on reader...");
  Serial.println();
  lcd.init(); // Initialize the LCD object
  lcd.backlight();
  lcd.clear();
  lcd.setCursor(0,0); // column, row
  lcd.print(" Scan Your RFID "); 
  lcd.setCursor(0,1); // column, row
  lcd.print("   Door Locked   ");
}
void loop() 
{
  if(digitalRead(Btn) == HIGH){
    openDoor();
  }

  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardfhdhPresent()) 
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCdfdgardSerial()) 
  {
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
    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) == "C2 79 EE 1B") //change here the UID of card/cards or tag/tags that you want to give access
  {
    openDoor();
  }
  else
  {
    lcd.setCursor(0,1); // column, row
    lcd.print("Invalid RFID Tag");
    Serial.println(" Access denied");
    digitalWrite(LED_R, HIGH);
    tone(BUZZER, 1500);
    delay(500);
    digitalWrite(LED_R, LOW);
    noTone(BUZZER);
    delay(100);
    digitalWrite(LED_R, HIGH);
    delay(100);
    digitalWrite(LED_R, HIGH);
    tone(BUZZER, 1500);
    delay(500);
    digitalWrite(LED_R, LOW);
    noTone(BUZZER);
    lcd.setCursor(0,1); // column, row
    lcd.print("   Door Locked   ");
  }
}



_ 🄸🄽🅂🅃🄰🄶🅁🄰🄼 👇🏾 https://z-p42.www.instagram.com/aryanpandey699/ _______________________________________________________ (ABOUT ) Welcome to the "TECHNO SAP" YouTube channel, where you can explore the fascinating world of science with me, Aryan Pandey. As the founder and host of this channel, I am dedicated to sharing my passion for science and delivering exciting and informative videos on various scientific topics. From mind-blowing experiments to cutting-edge discoveries and technologies, you'll find it all here on my channel. So, join me on this incredible journey of learning and discovery, and don't forget to hit that SUBSCRIBE button and turn on the notification bell to stay updated on my latest uploads. _________________________________________________________ If you're interested in exploring more of the world of science, you're in the right place. Join me as we dive into exciting experiments, mind-blowing discoveries, and cutting-edge technology. Hit the SUBSCRIBE button and turn on the notification bell to stay updated on my latest uploads. For any queries or questions, feel free to contact me on my email address, aryan2020pandey@gmail.com. Thank you for watching, and I look forward to sharing more valuable content with you soon. #TechnoSAP" 🙏🙏


Post a Comment

Previous Post Next Post