Arduino RFID Vault Safe
This project was just about having fun and making something with the goal of making 2 main components working together. In this project, it will use a RFID(radio-frequency identification) scanner and an servo motor. The RFID will be used along side with a servo motor to create a lock.
Supplies
you will need
1) 1 Arduino Uno
2) 1 Servo Motor
3) 1 Breadboard
4) 1 Button
5) 1 RFID
6) A lot of wires(Female to female and jumper wires)[You may use Female to Male wires if you want]
7) A lot of Cardboard
Building Steps
Set-up RFID sensor(construction of the box is not needed currently)
I will leave a link to another article of where I had learned to set-up the RFID sensor. This is important as you will need to do this in order for it to work. This is because every keycard/keytag has its own unique code to it. So you can't simply copy someone's code and be like "I'm all set to go". This part is the most crucial. The wiring layout is also shown in the article. But just in case, I will leave it here.
Set-up the BOX
The next part is setting up your box. This part is self explanatory, the box itself doesn't matter. If you want, you can have it premade or do what I have done and create the box yourself. The size of the box doesn't matter too much, just make sure it's not too small(If it's too small, how are you gonna store anything in there).
Code
#include
#include #include
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
Servo Servo1;
int button = 2;
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.println("Approximate your card to the reader...");
Serial.println();
Servo1.attach(3);
pinMode(button,INPUT);
}
void loop()
{
int buttonstate = digitalRead(button);
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
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) == "B5 E7 FB D1") //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized access");
Serial.println();
Servo1.write(180);
delay(3000);
}
else
{
Serial.println(" Access denied");
Servo1.write(90);
delay(3000);
}
}
This is the entire code, there is 2 things to be aware about. 1, the code may sometimes stop working, so just re upload the code and your good to go. 2, there is no locking mechanism other than using a keycard/keychain that doesn't match the code. So, the only way to lock it is to use a keycard/keychain that doesn't match.