jananga_dehipitiya
Published

RFID Card Door Lock

This can be used to enhance safety and security.

BeginnerFull instructions provided1,167
RFID Card Door Lock

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
RFID reader (generic)
×1
RFID Module (Generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
PCB Holder, Soldering Iron
PCB Holder, Soldering Iron

Story

Read more

Schematics

Diagram

The diagram of it

Code

Arduino Code

Arduino
This is the code
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>

#define SS_PIN 10
#define RST_PIN 9
#define SERVO_PIN 3
Servo myservo;
#define ACCESS_DELAY 2000
#define DENIED_DELAY 1000
MFRC522 mfrc522(SS_PIN, RST_PIN); 
void setup()
{
Serial.begin(9600); 
SPI.begin(); 
mfrc522.PCD_Init(); 
myservo.attach(SERVO_PIN);
myservo.write( 70 );
delay(7500);
myservo.write( 0 );
Serial.println("Put your card to the reader...");
Serial.println();
}
void loop()
{

if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}

if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}

Serial.print("UID tag :");

String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
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) == "E3 3F 87 34") 
{
Serial.println("Authorized access");
Serial.println();
myservo.write( 70 );
delay(5500);
myservo.write( 0 );
}
else {
Serial.println(" Access denied");

delay(DENIED_DELAY);

}
}

Credits

jananga_dehipitiya
1 project • 2 followers

Comments