Project tutorial
Security System And Access Control With Arduino And RFID

Security System And Access Control With Arduino And RFID © GPL3+

To enter passwords and to allow access to a door or to drive an electronic device, now we will use a RFID device.

  • 9,715 views
  • 1 comment
  • 22 respects

Components and supplies

Apps and online services

About this project

Instead of using a matricial keyboard, to enter passwords and to allow access to a door or to drive an electronic device, now we will use a RFID (Radio Frequency Identifier Device). We also will use a LCD Display with 20 character and 4 lines to show some messages from the system, besides a servo-motor to drive an mechanical device like (door's locks, turnstile, etc...). Users will have cards or tags registered to access the system. When approaching the card/tag to the RFID sensor (approximately 6 cm), the serial number of this card/tag is detected and so compared with a serial number that are recorded in the software or in a database on a memory card; if it is a registered serial number, the system will release the entry of this user. A green LED will be lit and some messages will be appearing in the LCD display (user recognition and user welcome), the buzzer will give access granted sound, besides that a servo will be drived to release a mechanical device. Otherwise, the system does not release the user access, and a warning red LED will be lit and will be showed a message on the LCD advising the user to contact the account manager.During this process of release or rejection of users, characteristics beeps will be played on a buzzer (just like a sound announcement).

Interconnections from the RFID to the Arduino pins:

  • Reset > Pin 8
  • SDA > Pin 10
  • MOSI > Pin 11
  • MISO > Pin 12
  • SCK > Pin 13
  • Ground > Ground
  • 3.3v > 3.3v

Interconnections from the DISPLAY to the Arduino pins:

  • Vss > Ground
  • Vdd > +5v
  • V0 > one pin of potntiometer | 2nd pin of pot to 5v |3rd pin to ground
  • Rs > Pin 7
  • R/w > Ground
  • E > Pin 6
  • D0,D1,D2,D3 > no connection
  • D4 > Pin 5
  • D5 > Pin 4
  • D6 > Pin 3
  • D7 > Pin 2
  • A > +5v
  • K > ground

Interconnections from the SERVO to the Arduino pins:

  • Control pin > Pin 9
  • Vcc > +5v
  • Ground > Ground

Interconnections from the BUZZER to the Arduino pins:

  • Positive pin > Pin A2
  • Ground > Ground

Interconnections from the GREEN LED to the Arduino pins:

  • Positive pin > Pin A1
  • Ground > Ground

Interconnections from the GREEN LED to the Arduino pins:

  • Positive pin > Pin A0
  • Ground > Ground

Upload the given code to the Arduino. Connect the components:

Code

arduino codeArduino
#include <LiquidCrystal.h> //lcd library
/*Thudangi*/
#include <Servo.h> //servo library
int servoPin = 9; 
Servo Servo1;

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

int red=A0;
int green=A1;

#include <MFRC522.h> // RFID Library
#include <SPI.h> // For communication via SPI with the Module



#define SDAPIN 10 // RFID Module SDA Pin is connected to the UNO 10 Pin
#define RESETPIN 8 // RFID Module RST Pin is connected to the UNO 8 Pin
byte FoundTag; // Variable used to check if Tag was found
byte ReadTag; // Variable used to store anti-collision value to read Tag information
byte TagData[MAX_LEN]; // Variable used to store Full Tag Data
byte TagSerialNumber[5]; // Variable used to store only Tag Serial Number
byte GoodTagSerialNumber[5] = {0x0E, 0x4A, 0x79, 0x21}; // The Tag S/N. give your rfid tag identity code here

MFRC522 nfc(SDAPIN, RESETPIN); // Init of the library using the UNO pins declared above

void setup() {
Servo1.attach(servoPin);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
lcd.begin(20, 4);
  // Print a message to the LCD.
lcd.setCursor(0,0);
lcd.print("RFID SECURITY SYSTEM"); // give here the comments you need show the display
delay(200);
lcd.setCursor(2,1);
lcd.print(" PROJECT DONE BY   ");  // give here the comments you need show the display
delay(200);
lcd.setCursor(0,3);
lcd.print("  S6 ELS 2014-2017");    // give here the comments you need show the display
delay(1000);
lcd.setCursor(0,2);
lcd.print("    LIJIN ASHOK  ");   // give here the comments you need show the display
delay(2000);
lcd.setCursor(0,2);
lcd.print("     MIDHUN M S");   // give here the comments you need show the display
delay(2000);
lcd.setCursor(0,2);
lcd.print("    PRABHU Y RAJ");   // give here the comments you need show the display
 delay(2000);
lcd.setCursor(0,2);
lcd.print("      SARATH P  ");   // give here the comments you need show the display
delay(2000);
lcd.setCursor(0,2);
lcd.print("    SREEJITH R S  ");   // give here the comments you need show the display
delay(2000);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
SPI.begin();
Serial.begin(9600);

// Start to find an RFID Module
Serial.println("Looking for RFID Reader");
nfc.begin();
byte version = nfc.getFirmwareVersion(); // Variable to store Firmware version of the Module

// If can't find an RFID Module 
if (! version) { 
Serial.print("Didn't find RC522 board.");
while(1); //Wait until a RFID Module is found
}

// If found, print the information about the RFID Module
Serial.print("Found chip RC522 ");
Serial.print("Firmware version: 0x");
Serial.println(version, HEX);
Serial.println();
}

void loop() {
 Servo1.write(0);
 delay(300);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("RFID SECURITY SYSTEM");
lcd.setCursor(4,3);
lcd.print("SHOW YOUR ID");
lcd.noDisplay();
delay(200);
lcd.display();
delay(250);
String GoodTag="False"; // Variable used to confirm good Tag Detected

// Check to see if a Tag was detected
// If yes, then the variable FoundTag will contain "MI_OK"
FoundTag = nfc.requestTag(MF1_REQIDL, TagData);

if (FoundTag == MI_OK) {
delay(200);

// Get anti-collision value to properly read information from the Tag
ReadTag = nfc.antiCollision(TagData);
memcpy(TagSerialNumber, TagData, 4); // Write the Tag information in the TagSerialNumber variable

Serial.println("Tag detected.");
Serial.print("Serial Number: ");
for (int i = 0; i < 4; i++) { // Loop to print serial number to serial monitor
Serial.print(TagSerialNumber[i], HEX);
Serial.print(", ");
}
Serial.println("");
Serial.println();



// Check if detected Tag has the right Serial number we are looking for 
for(int i=0; i < 4; i++){
if (GoodTagSerialNumber[i] != TagSerialNumber[i]) {
break;
}
if (i == 3) {
GoodTag="TRUE";
} 
}
if (GoodTag == "TRUE"){
 lcd.clear();
 lcd.setCursor(0,0);
lcd.print("RFID SECURITY SYSTEM");
 lcd.setCursor(3, 1);
 lcd.print("ACCESS GRANTED");
 lcd.setCursor(0,3);
 digitalWrite(A1, HIGH);
 lcd.print(" +----WELCOME----+");
 digitalWrite(A2, HIGH);
 delay(300);
digitalWrite(A2, LOW);
 delay(300);
 digitalWrite(A2, HIGH);
 delay(300);
 digitalWrite(A2, LOW);
 delay(300);
 digitalWrite(A2, HIGH);
 delay(300);
 digitalWrite(A2, LOW);
 delay(300);
 digitalWrite(A2, HIGH);
 delay(300);
 digitalWrite(A2, LOW);
 delay(300);
 digitalWrite(A2, HIGH);
 delay(300);
 digitalWrite(A2,LOW);
 Servo1.write(180);
delay(7000);
Servo1.write(0);
digitalWrite(A1, LOW);
}
else {
 lcd.clear();
 lcd.setCursor(0,0);
lcd.print("RFID SECURITY SYSTEM");
 lcd.setCursor(3, 1);
 lcd.print("ACCESS DENIED");
digitalWrite(A1,LOW);
delay(100);
 lcd.setCursor(0,3);
 lcd.print(" UNAUTHORIZED ENTRY");
 digitalWrite(A2, HIGH);
 delay(150);
digitalWrite(A2, LOW);
 delay(150);
 digitalWrite(A2, HIGH);
 delay(150);
 digitalWrite(A2, LOW);
 delay(150);
 digitalWrite(A2, HIGH);
 delay(150);
 digitalWrite(A2,LOW);
 delay(150);
 digitalWrite(A2, HIGH);
 delay(150);
 digitalWrite(A2, LOW);
 delay(150);
 digitalWrite(A2, HIGH);
 delay(150);
 digitalWrite(A2,LOW);
digitalWrite(A0, HIGH);
delay(3000);
digitalWrite(A0, LOW);
}
delay(200); 
}
}

Schematics

circuit diagram
Untitled qaldfherth

Comments

Similar projects you might like

Ultrasonic Security System

Project tutorial by Ivan

  • 17,303 views
  • 18 comments
  • 50 respects

Security Access Using RFID Reader

by Aritro Mukherjee

  • 260,260 views
  • 42 comments
  • 281 respects

Buzzer Alarm System With Help Of Arduino

by Team ONYX

  • 37,878 views
  • 5 comments
  • 21 respects

RFID Based Automatic Door System

Project showcase by Robodia Technology

  • 35,759 views
  • 20 comments
  • 97 respects

Android App-Based Home Automation System Using IOT

Project tutorial by Team Autoshack

  • 24,825 views
  • 17 comments
  • 75 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,591 views
  • 5 comments
  • 17 respects
Add projectSign up / Login