Hey Guys, welcome back to another new post. In this article, we are going to make an RFID Arduino gate security system. You will find the working of this technology in the Metro gate and the parking gate. The gates only open when you tap your token or key card. You can also make this project and use it on your homes as it is very simple to make it. For more information about this project visit the original post of this project also bookmark TECHATRONIC.COM as all my further projects and tutorials will be pre-uploaded there. We are using an RC522 RFID reader/writer module and a servo motor for opening and closing the door. The whole system is controlled by the Arduino. All the necessary details regarding the project are given below.
In this project, we are using radiofrequency technology for opening and closing the gate. You can add as much cards information in the system. Whenever you put the wrong card on the reader the doors will not open as the information didn't match on the system with the card id. You have to put the right card on the reader module so that the servo motor can rotate. The door is mechanically connected to the servo motor. It will open and after a delay of a few seconds, it will close automatically. First, we have to extract the tag value by tapping a single card to the reader. when we tap a card to the reader we get a value from the tag and we can add this unique value to the database.
RFID Arduino security lock Circuit diagram:-NOTE: Please upload the code which is given below and install the required libraries to the Arduino IDE.
#include "SPI.h"
#include "MFRC522.h"
#include
#define SS_PIN 10
#define RST_PIN 9
#include
int m=0,n=0;
Servo myservo;
int pos = 0;
MFRC522 rfid(SS_PIN, RST_PIN);
MFRC522::MIFARE_Key key;
const int rs = 0, en = 6, d4 = 5, d5 = 4, d6 = 2, d7 = 1;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
lcd.begin(16, 2);
myservo.attach(3);
}
void loop() {
m= analogRead(A3);
n= analogRead(A2);
int val_1= map(m, 250 , 850 , 0 , 100);
int val_2= map(n, 250, 850, 0, 100);
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial())
return;
// Serial.print(F("PICC type: "));
MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
// Serial.println(rfid.PICC_GetTypeName(piccType));
// Check is the PICC of Classic MIFARE type
if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI &&
piccType != MFRC522::PICC_TYPE_MIFARE_1K &&
piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
Serial.println(F("Your tag is not of type MIFARE Classic."));
return;
}
String strID = "";
for (byte i = 0; i < 4; i++) {
strID +=
(rfid.uid.uidByte[i] < 0x10 ? "0" : "") + String(rfid.uid.uidByte[i], HEX) + (i!=3 ? ":" : ""); } strID.toUpperCase(); Serial.print("Tap card key: "); Serial.println(strID); if(strID.indexOf("1A:28:54:73")>=0)
{
Serial.println("card accepted");
digitalWrite(A0, HIGH);
lcd.setCursor(0, 1);
lcd.print("Speed Limit= ");
lcd.print(val_2);
delay(1000);
lcd.clear();
digitalWrite(A0, LOW);
myservo.write(0);
myservo.write(90); // tell servo to go to position in variable 'pos'
delay(15);
delay(2000);// waits 15ms for the servo to reach the position
myservo.write(0); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
else
{
digitalWrite(A0, LOW);
}
if(strID.indexOf("1A:28:54:73")>=0)
{
Serial.println("Token Accepted");
digitalWrite(A1, HIGH);
lcd.setCursor(0, 1);
lcd.print("Speed Limit= ");
lcd.print(val_1);
delay(1000);
lcd.clear();
digitalWrite(A1, LOW);
}
else
{
digitalWrite(A1, LOW);
}
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1();
}
You can also watch the video tutorial of this ProjectHAPPY LEARNING!
Comments
Please log in or sign up to comment.