Skip to main content

DIY RFID BASED AUTOMATIC DOOR MANAGEMENT SYSTEM

Secure your home by implementing this handy automatic door 
Management system.


 WHAT YOU NEED :

    Arduino Uno

    16×2 LCD display

    Servo motor 

    RFID RC522 module and Card

    Buzzer

    Resistor 221 ohm

    Breadboard

    Jumper wires


   CIRCUIT DIAGRAM :





  CODE :

/* 
 *  RFID Module RC522
 *  Simple Project:- Arduino will read RFID Tag and Display To the Serial Monitor!
 *  
 *  RFID RC522 and Arduino Uno Pin Configuration
 *  
 *  RFID RC522          Arduino Uno
 *  SS/SDA              D10
 *  SCK                 D13
 *  MOSI                D11
 *  MISO                D12
 *  IRQ                 Not Connected
 *  GND                 GND
 *  RST                 D9
 *  3.3V                3.3V
 *  
 *  //Note: We connected LCD to the Analog Pins.
 *  Remember, Analog Pins can be act as a Digital Pins,
 *  But Digital Pins CAN NOT be act as a Analog Pins.
 *  
 *  LCD(16x2) Connections
 *  
 *  VSS pin to GND
 *  VCC pin to 5V
 *  //We are connecting "Contrast pin to GND for Maximum Brightness"
 *  //You can also connect it to 10K Pot if you wish to change the Brightness Of LCD.
 *  VEE pin to GND 
 *  RS pin to Analog pin A0
 *  R/W pin to ground
 *  Enable pin to Analog pin A1
 *  D4 pin to Analog pin 5
 *  D5 pin to Analog pin 4
 *  D6 pin to Analog pin 3
 *  D7 pin to Analog pin 2
 *  LED+ pin to POWER
 *  LED- pin to GND 
 *   
 *  Servo is Connected to Digital Pin 5  
 *  
 *  RGB LED
 *  From RGB LED, We need Only Red and Green Color, 
 *  So we are not connecting Blue pin of the RGB. 
 *  
 *  Red pin to Digital pin 6
 *  Green pin to Digital pin 7
 *  
 *  Buzzer to Digital pin 8
 * 
 *  
 *  Note:- RFID uses SPI Protocol to transfer the information.
 *  I took the Melody(for the Buzzer) from, 
 *  File -> Examples -> Digital -> ToneMelody
*/

//Include sections
#include <RFID.h>
#include <SPI.h>
#include <LiquidCrystal.h>
#include <Servo.h>
#include "pitches.h"

//Define Component to Arduino Pins
#define SS_PIN 10
#define RST_PIN 9

#define SERVO_PIN 5

#define Red_LED 6
#define Green_LED 7

#define Buzzer 8


//initialize the library with the numbers of the interface pins
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);
Servo DoorLock;
RFID rfid(SS_PIN, RST_PIN );

//Unique ID of RFID Tag, which you want to give access. 
int My_RFID_Tag[5] = {0x58,0x76,0x17,0x10,0x29};

//variable to hold your Access_card
boolean My_Card = false;  
   
// notes in the melody, taken from:
//File -> Examples -> Digital -> ToneMelody
int melody[] = {
  NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 8, 8, 4, 4, 4, 4, 4
};

void setup() 
{
  // put your setup code here, to run once:
  //set the pins as an input/output
  pinMode(Red_LED,OUTPUT);
  pinMode(Green_LED,OUTPUT);
  pinMode(Buzzer,OUTPUT);
  
  //Servo Connnected to pin Digital Pin 5
  DoorLock.attach(SERVO_PIN);
  //open the serial port at 9600 baudrate.
  Serial.begin(9600); 
  //Initialise the LCD to 16x2 Character Format
  lcd.begin(16,2);
  //Initialise Servo and RFID
  SPI.begin();
  rfid.init();
}

void loop() 
{
  // put your main code here, to run repeatedly:
  
  //First Assume detected card(Or tag) is My_Card, 
  //Then later we will check is it My_Card or not! 
  My_Card = true; 
  DoorLock.write(0); //Servo at 0 Position, Door is Closed.
  lcd.clear();
  lcd.print("Robodia Technology");
  lcd.setCursor(0,1);
  lcd.print("gy Solutions!");
  
  //Check if any RFID Tags Detected or not?
  if( rfid.isCard() )
  {
      //if RFID Tag is detected, check for the Unique ID,
      //and print it on the Serial Window
      if( rfid.readCardSerial() )
      {   
          lcd.clear();      
          lcd.print("UNIQUE ID is:- ");
          delay(500);          
          lcd.setCursor(0,1); //Set LCD Cursor to Second Row, First Character
  
      //Unique id is 5 Digit Number.
          //Printing in HEX for better Understanding
          for( int i = 0; i < 5; i++ )
          {
              Serial.print(rfid.serNum[i], HEX);
              Serial.print(" ");              
              lcd.print(rfid.serNum[i],HEX);
              lcd.print(" ");                            
          }  
          delay(500);
          
      //Compare this RFID Tag Unique ID with your My_RFID_Tag's Unique ID
          for(int i = 0; i < 5; i++)
          {   
              //if any one Unique ID Digit is not matching,
              //then make My_Card = false and come out from loop
              //No need to check all the digit!
              if( My_RFID_Tag[i] != rfid.serNum[i] )
              {
                My_Card = false;
                break;                
              }           
          }
          Serial.println(); 
          delay(1000); 

          //If RFID Tag is My_Card then give access to enter into room
          //else dont open the door.
          if(My_Card)
          {
            Serial.println("\nWelcome To Your Room, Robodia!");
            lcd.clear();
            lcd.print("Welcome to Your");
            lcd.setCursor(0,1);
            lcd.print("Room, Robodia!");
            delay(2000);                        
            
            //Turn on the Green LED as an indication of permission is given 
            //to access the room.
            digitalWrite(Green_LED,HIGH);
            
            //Buzzer Config, taken from:
            //File -> Examples -> Digital -> ToneMelody
            // iterate over the notes of the melody:
            int i = 0;
            while(i < 2)
            {
              for (int thisNote = 0; thisNote < 12; thisNote++) 
              {          
                // to calculate the note duration, take one second
                // divided by the note type.
                //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
                int noteDuration = 1000 / noteDurations[thisNote];
                tone(8, melody[thisNote], noteDuration);                        
                // to distinguish the notes, set a minimum time between them.
                // the note's duration + 30% seems to work well:
                int pauseBetweenNotes = noteDuration * 1.30;
                delay(pauseBetweenNotes);              
                // stop the tone playing:
                noTone(8);
              }
              i =  i + 1;
              delay(500);              
            }
            delay(1000);            

            //Now, Open the Door with the help of Servo Motor
            DoorLock.write(180);            
            delay(200);
            lcd.clear();                                    
            lcd.print("Door is Open");
            lcd.setCursor(0,1);
            lcd.print("Now!");
            delay(2000);
            lcd.clear();

            //Give 10 Sec delay to enter into room
            //After that door will again closed!
            for(int i = 10; i > 0; i--)
            {
              lcd.print("Door will close");
              lcd.setCursor(0,1);
              lcd.print("in ");
              lcd.print(i);
              lcd.print(" Sec.HurryUp!");
              delay(1000);
              lcd.clear();
            }

            //Now,Door is closed and Green LED is Turned-Off.
            DoorLock.write(0);
            digitalWrite(Green_LED,LOW);
            delay(200);
            lcd.clear();
            lcd.print("Door is Close");
            lcd.setCursor(0,1);
            lcd.print("Now!");
            delay(2000);                            
          }
          
          // If RFID Tag is not My_Card then
          // Do not open the Door and 
          //Turn-On Red LED and Buzzer as an indication of Warning:
          //Somebody else is trying to enter into your room. 
          else
          {
            Serial.println("\nGet Out of Here !");
            lcd.clear();
            lcd.print("Card isNOT FOUND!");
            lcd.setCursor(0,1);
            lcd.print("Get Out of Here!");

            for(int i = 0; i < 7; i++)
            {
              digitalWrite(Buzzer, HIGH);
              digitalWrite(Red_LED,HIGH);
              delay(500);
              digitalWrite(Buzzer, LOW);
              digitalWrite(Red_LED,LOW);
              delay(500);              
            }
            delay(1000);            
          }                 
      }      
   }
  //Put RFID Reader into Halt, untill it not detects any RFID Tag.
  rfid.halt();
}

 Making electronics project is too pretty 

 Simple with Us.


Join and Make with Us.



Comments

Popular posts from this blog

How to use ADXL345 accelerometer with raspberry pi

 Hey,  Today's blog we are going to use ADXL345   Accelerometer with raspberry pi. WHAT YOU NEED : Raspberry pi 3 SD card (8gb+ recommend) Power supply ADXL345 accelerometer  Breadboard CIRCUIT :  PREPARING RASPBERRY PI : 1.  Before we can get our Raspberry Pi to retrieve data from our ADXL345 Accelerometer, there are a few changes we must make to the Pi’s configuration. Let’s first ensure that everything is up to date by running the following two commands. sudo apt-get update sudo apt-get upgrade 2.  Once the Raspberry Pi has finished updating, we will need to go ahead and launch the Raspberry configuration tool so that we can  enable I2C  on the Raspberry Pi. Run the following command to launch the  raspi configuration tool . sudo raspi-config 3.  On this screen, you need to head to the “ 5 Interfacing Options ” menu. You can navigate the  raspi-config  tools menus by using the  arrow keys . Use the  ENTER...

How To Make Pac- Man Game Using Arduino

Hello Guys , In This Post We Will Tell You How To Make A Arduino Based Pac- Man Game. For More Awesome Arduino Projects Subscribe Our Blog. #Microelectronics Components Required- 1-Arduino Uno / Nano  2-Display Module  3- Joystick Module  4- Jumper Wire   Circuit Diagram Is Given Below- Source Code- //Nokia 5110 LCD PacMan Game #include <LCD5110_Graph.h> #include <avr/pgmspace.h> #define RST 12    // RESET #define CE  13    // CS #define DC  11    // Data/Command #define DIN  10   // MOSI #define CLK  9    // SCK LCD5110 myGLCD(CLK, DIN, DC, RST, CE); // LCD5110(SCK, MOSI, DC, RST, CS); extern uint8_t SmallFont[]; const uint8_t pacman1[] PROGMEM={ 0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x3E, 0x1C,   // 0x0010 (16) pixels 0x0C, 0x00, 0x00, 0x00, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, ...

DIY fingerprint based car ignition system

  Hey, In today's blog we are going to make a fingerprint based car ignition system. WHAT YOU NEED : Arduino nano R305 fingerprint sensor EM18 RFID reader 16×2 LCD display DC motor L293D motor driver Breadboard Connecting wire 12v battery CODE : #include <Adafruit_Fingerprint.h> #include <LiquidCrystal.h> char input[12]; int count = 0; int a = 0; const int rs = 6, en = 7, d4 = 2, d5 = 3, d6 = 4, d7 = 5; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); SoftwareSerial mySerial(12,11); Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); void setup() {    pinMode(9,OUTPUT);    pinMode(10,OUTPUT);    digitalWrite(9,LOW);    digitalWrite(10,LOW);    Serial.begin(9600);    lcd.begin(16, 2);    lcd.setCursor(0, 0);    lcd.print( "   WELCOME TO       " );    lcd.setCursor(0, 1);    lcd.print( "  CIRCUIT DIGEST  ...