#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);
}
}
Comments