RFID-RC522 module is a module used for data reader of RFID card. Any RFID or other RFID Tags may be keychains and so have unique IDs, or one with another are different. The ID is used to be programmed as a security, so when there is an ID that does not match the program, then Arduino will give the command that the ID does not match. In this project when the ID of the RFID matches, it can be used to control the Relay which can then be connected to another device as a security. So, before trying this project, then you must know in advance the ID of the RFID card you have. The RFID Card ID Reading Program has been available on this blog under the title "Interfacing RFID".
Hardware Requirement
- RC522 RFID Module
- RFID Card
- Buzzer
- Relay 1 Channel Module
- LCD 16x2
- Power supply +5 Volt
- Jumper
RFID RC522 and RFID Tag | Source
Block Diagram
Schematic
Arduino - RFID Module Wiring
Arduino - LCD Module Wiring
Arduino - Relay Module
Source Code/Sketch
#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define RST_PIN 9
#define SS_PIN 10
MFRC522 mfrc522(SS_PIN, RST_PIN);
MFRC522::MIFARE_Key key;
byte noID[3];
byte i, kursor, kunci;
byte bukaPintu=1;
void setup() {
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
lcd.begin(16, 2);
SPI.begin();
mfrc522.PCD_Init();
lcd.setCursor(0,0);
lcd.print(" Kunci Motor");
lcd.setCursor(0,1);
lcd.print("Elektrik dg RFID");
delay(3000);
digitalWrite(A0, 1);
delay(100);
digitalWrite(A0, 0);
delay(100);
digitalWrite(A0, 1);
delay(100);
digitalWrite(A0, 0);
delay(100);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Kunci Elektrik");
lcd.setCursor(0,1);
lcd.print(" Aktif");
digitalWrite(A1, 1);
kunci=1;
}
void loop() {
if(!mfrc522.PICC_IsNewCardPresent()|| !mfrc522.PICC_ReadCardSerial()){
return;
}
for (i=0; i<mfrc522.uid.size; i++) {
noID[i]=mfrc522.uid.uidByte[i];
}
lcd.clear();
//----------------nomor ID E6 BB FE 48
if (0XE6 == noID[0] && 0XBB == noID[1] &&
0XFE == noID[2] && 0X48 == noID[3] ) {
if (kunci==0){
digitalWrite(A0, 1);
delay(100);
digitalWrite(A0, 0);
delay(100);
digitalWrite(A0, 1);
delay(100);
digitalWrite(A0, 0);
delay(100);
lcd.print(" Kunci Elektrik");
lcd.setCursor(0,1);
lcd.print(" Aktif");
digitalWrite(A1, 1);
kunci=1;
}
else{
digitalWrite(A0, 1);
delay(100);
digitalWrite(A0, 0);
delay(100);
lcd.print(" Kunci Elektrik");
lcd.setCursor(0,1);
lcd.print(" Tidak Aktif");
digitalWrite(A1, 0);
kunci=0;
}
}
else{
lcd.print(" kartu ID Anda");
lcd.setCursor(0,1);
lcd.print("tidak terdaftar");
}
delay(2000);
#include <MFRC522.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define RST_PIN 9
#define SS_PIN 10
MFRC522 mfrc522(SS_PIN, RST_PIN);
MFRC522::MIFARE_Key key;
byte noID[3];
byte i, kursor, kunci;
byte bukaPintu=1;
void setup() {
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
lcd.begin(16, 2);
SPI.begin();
mfrc522.PCD_Init();
lcd.setCursor(0,0);
lcd.print(" Kunci Motor");
lcd.setCursor(0,1);
lcd.print("Elektrik dg RFID");
delay(3000);
digitalWrite(A0, 1);
delay(100);
digitalWrite(A0, 0);
delay(100);
digitalWrite(A0, 1);
delay(100);
digitalWrite(A0, 0);
delay(100);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Kunci Elektrik");
lcd.setCursor(0,1);
lcd.print(" Aktif");
digitalWrite(A1, 1);
kunci=1;
}
void loop() {
if(!mfrc522.PICC_IsNewCardPresent()|| !mfrc522.PICC_ReadCardSerial()){
return;
}
for (i=0; i<mfrc522.uid.size; i++) {
noID[i]=mfrc522.uid.uidByte[i];
}
lcd.clear();
//----------------nomor ID E6 BB FE 48
if (0XE6 == noID[0] && 0XBB == noID[1] &&
0XFE == noID[2] && 0X48 == noID[3] ) {
if (kunci==0){
digitalWrite(A0, 1);
delay(100);
digitalWrite(A0, 0);
delay(100);
digitalWrite(A0, 1);
delay(100);
digitalWrite(A0, 0);
delay(100);
lcd.print(" Kunci Elektrik");
lcd.setCursor(0,1);
lcd.print(" Aktif");
digitalWrite(A1, 1);
kunci=1;
}
else{
digitalWrite(A0, 1);
delay(100);
digitalWrite(A0, 0);
delay(100);
lcd.print(" Kunci Elektrik");
lcd.setCursor(0,1);
lcd.print(" Tidak Aktif");
digitalWrite(A1, 0);
kunci=0;
}
}
else{
lcd.print(" kartu ID Anda");
lcd.setCursor(0,1);
lcd.print("tidak terdaftar");
}
delay(2000);
How it Works (Motorcycle Security)
1. Connect the Arduino with Peripherals needed.
2. Plug in the Power Source on the device.
3. Add some library if needed
4. Compile and upload the script program above to your arduino.
5. First initial LCD display
2. Next the electric key is active, buzzer will rang two times and LCD displays "active"
3. Append the ID Card to the RFID module to disable the electric lock, buzzer will rang one time.
Video for Project V - 13. Security System with RFID based On Arduino
Required file
No comments:
Post a Comment