Components and supplies
RIFD Reader RC522
Single Turn Potentiometer- 10k ohms
Arduino UNO
Jumper wires (generic)
Breadboard (generic)
Standard LCD - 16x2 White on Blue
Project description
Code
RFID Reader Write with LCD
arduino
This the actual RFID lock
1//All Credit Technic 1510 2// 3// 4// 5// 6#include <SPI.h> 7#include <MFRC522.h> 8#include <LiquidCrystal.h> 9#define SS_PIN 10 10#define RST_PIN 9 11MFRC522 mfrc522(SS_PIN, RST_PIN); 12LiquidCrystal lcd(6 , 7, 5, 4, 3, 2); 13 14 15void setup() 16{ 17 18 SPI.begin(); 19 mfrc522.PCD_Init(); 20 lcd.begin(16, 2); 21 lcd.print("Scan RFID Card"); 22 23 24} 25void loop() 26{ 27 28 if ( ! mfrc522.PICC_IsNewCardPresent()) 29 { 30 return; 31 } 32 33 if ( ! mfrc522.PICC_ReadCardSerial()) 34 { 35 return; 36 } 37 38 lcd.clear(); 39 lcd.begin(16, 2); 40 lcd.print("UID tag :"); 41 String content= ""; 42 byte letter; 43 for (byte i = 0; i < mfrc522.uid.size; i++) 44 { 45 lcd.setCursor(0, 1); 46 lcd.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); 47 lcd.print(mfrc522.uid.uidByte[i], HEX); 48 content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); 49 content.concat(String(mfrc522.uid.uidByte[i], HEX)); 50 } 51lcd.clear(); 52lcd.begin(16, 2); 53 lcd.print("Message : "); 54 content.toUpperCase(); 55 if (content.substring(1) == "E0 28 E9 87") //Plz change to your cards UID 56 { 57 lcd.setCursor(0,1); 58 lcd.print("Authorized"); 59 60 delay(3000); 61 lcd.clear(); 62 setup(); 63 } 64 65 else { 66 lcd.setCursor(0, 1); 67 lcd.print(" Access denied"); 68 delay(3000); 69 lcd.clear(); 70 setup(); 71 } 72} 73
RFID Reader (Data Reader)
arduino
Please use this to find your cards ID. THIS ALSO CHANGES THE UID So you can have a different one
1//All credit to Technic1510 2// 3// 4// 5// 6// 7#include <SPI.h> 8#include <MFRC522.h> 9 10#define RST_PIN 9 // Configurable, see typical pin layout above 11#define SS_PIN 10 // Configurable, see typical pin layout above 12 13MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance 14 15/* Set your new UID here! */ 16#define NEW_UID {0xDE, 0xAD, 0xBE, 0xEF} 17 18MFRC522::MIFARE_Key key; 19 20void setup() { 21 Serial.begin(9600); // Initialize serial communications with the PC 22 while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 23 SPI.begin(); // Init SPI bus 24 mfrc522.PCD_Init(); // Init MFRC522 card 25 Serial.println(F("Warning: this example overwrites the UID of your UID changeable card, use with care!")); 26 27 // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory. 28 for (byte i = 0; i < 6; i++) { 29 key.keyByte[i] = 0xFF; 30 } 31} 32 33// Setting the UID can be as simple as this: 34//void loop() { 35// byte newUid[] = NEW_UID; 36// if ( mfrc522.MIFARE_SetUid(newUid, (byte)4, true) ) { 37// Serial.println("Wrote new UID to card."); 38// } 39// delay(1000); 40//} 41 42// But of course this is a more proper approach 43void loop() { 44 45 // Look for new cards, and select one if present 46 if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) { 47 delay(50); 48 return; 49 } 50 51 // Now a card is selected. The UID and SAK is in mfrc522.uid. 52 53 // Dump UID 54 Serial.print(F("Card UID:")); 55 for (byte i = 0; i < mfrc522.uid.size; i++) { 56 Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); 57 Serial.print(mfrc522.uid.uidByte[i], HEX); 58 } 59 Serial.println(); 60 61 // Dump PICC type 62// MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); 63// Serial.print(F("PICC type: ")); 64// Serial.print(mfrc522.PICC_GetTypeName(piccType)); 65// Serial.print(F(" (SAK ")); 66// Serial.print(mfrc522.uid.sak); 67// Serial.print(")\ \ 68"); 69// if ( piccType != MFRC522::PICC_TYPE_MIFARE_MINI 70// && piccType != MFRC522::PICC_TYPE_MIFARE_1K 71// && piccType != MFRC522::PICC_TYPE_MIFARE_4K) { 72// Serial.println(F("This sample only works with MIFARE Classic cards.")); 73// return; 74// } 75 76 // Set new UID 77 byte newUid[] = NEW_UID; 78 if ( mfrc522.MIFARE_SetUid(newUid, (byte)4, true) ) { 79 Serial.println(F("Wrote new UID to card.")); 80 } 81 82 // Halt PICC and re-select it so DumpToSerial doesn't get confused 83 mfrc522.PICC_HaltA(); 84 if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) { 85 return; 86 } 87 88 // Dump the new memory contents 89 Serial.println(F("New UID and contents:")); 90 mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); 91 92 delay(2000); 93} 94
RFID Reader (Data Reader)
arduino
Please use this to find your cards ID. THIS ALSO CHANGES THE UID So you can have a different one
1//All credit to Technic1510 2// 3// 4// 5// 6// 7#include <SPI.h> 8#include <MFRC522.h> 9 10#define RST_PIN 9 // Configurable, see typical pin layout above 11#define SS_PIN 10 // Configurable, see typical pin layout above 12 13MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance 14 15/* Set your new UID here! */ 16#define NEW_UID {0xDE, 0xAD, 0xBE, 0xEF} 17 18MFRC522::MIFARE_Key key; 19 20void setup() { 21 Serial.begin(9600); // Initialize serial communications with the PC 22 while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 23 SPI.begin(); // Init SPI bus 24 mfrc522.PCD_Init(); // Init MFRC522 card 25 Serial.println(F("Warning: this example overwrites the UID of your UID changeable card, use with care!")); 26 27 // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory. 28 for (byte i = 0; i < 6; i++) { 29 key.keyByte[i] = 0xFF; 30 } 31} 32 33// Setting the UID can be as simple as this: 34//void loop() { 35// byte newUid[] = NEW_UID; 36// if ( mfrc522.MIFARE_SetUid(newUid, (byte)4, true) ) { 37// Serial.println("Wrote new UID to card."); 38// } 39// delay(1000); 40//} 41 42// But of course this is a more proper approach 43void loop() { 44 45 // Look for new cards, and select one if present 46 if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) { 47 delay(50); 48 return; 49 } 50 51 // Now a card is selected. The UID and SAK is in mfrc522.uid. 52 53 // Dump UID 54 Serial.print(F("Card UID:")); 55 for (byte i = 0; i < mfrc522.uid.size; i++) { 56 Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); 57 Serial.print(mfrc522.uid.uidByte[i], HEX); 58 } 59 Serial.println(); 60 61 // Dump PICC type 62// MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); 63// Serial.print(F("PICC type: ")); 64// Serial.print(mfrc522.PICC_GetTypeName(piccType)); 65// Serial.print(F(" (SAK ")); 66// Serial.print(mfrc522.uid.sak); 67// Serial.print(")\ \ 68"); 69// if ( piccType != MFRC522::PICC_TYPE_MIFARE_MINI 70// && piccType != MFRC522::PICC_TYPE_MIFARE_1K 71// && piccType != MFRC522::PICC_TYPE_MIFARE_4K) { 72// Serial.println(F("This sample only works with MIFARE Classic cards.")); 73// return; 74// } 75 76 // Set new UID 77 byte newUid[] = NEW_UID; 78 if ( mfrc522.MIFARE_SetUid(newUid, (byte)4, true) ) { 79 Serial.println(F("Wrote new UID to card.")); 80 } 81 82 // Halt PICC and re-select it so DumpToSerial doesn't get confused 83 mfrc522.PICC_HaltA(); 84 if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) { 85 return; 86 } 87 88 // Dump the new memory contents 89 Serial.println(F("New UID and contents:")); 90 mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); 91 92 delay(2000); 93} 94
RFID Reader Write with LCD
arduino
This the actual RFID lock
1//All Credit Technic 1510 2// 3// 4// 5// 6#include <SPI.h> 7#include <MFRC522.h> 8#include <LiquidCrystal.h> 9#define SS_PIN 10 10#define RST_PIN 9 11MFRC522 mfrc522(SS_PIN, RST_PIN); 12LiquidCrystal lcd(6 , 7, 5, 4, 3, 2); 13 14 15void setup() 16{ 17 18 SPI.begin(); 19 mfrc522.PCD_Init(); 20 lcd.begin(16, 2); 21 lcd.print("Scan RFID Card"); 22 23 24} 25void loop() 26{ 27 28 if ( ! mfrc522.PICC_IsNewCardPresent()) 29 { 30 return; 31 } 32 33 if ( ! mfrc522.PICC_ReadCardSerial()) 34 { 35 return; 36 } 37 38 lcd.clear(); 39 lcd.begin(16, 2); 40 lcd.print("UID tag :"); 41 String content= ""; 42 byte letter; 43 for (byte i = 0; i < mfrc522.uid.size; i++) 44 { 45 lcd.setCursor(0, 1); 46 lcd.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); 47 lcd.print(mfrc522.uid.uidByte[i], HEX); 48 content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); 49 content.concat(String(mfrc522.uid.uidByte[i], HEX)); 50 } 51lcd.clear(); 52lcd.begin(16, 2); 53 lcd.print("Message : "); 54 content.toUpperCase(); 55 if (content.substring(1) == "E0 28 E9 87") //Plz change to your cards UID 56 { 57 lcd.setCursor(0,1); 58 lcd.print("Authorized"); 59 60 delay(3000); 61 lcd.clear(); 62 setup(); 63 } 64 65 else { 66 lcd.setCursor(0, 1); 67 lcd.print(" Access denied"); 68 delay(3000); 69 lcd.clear(); 70 setup(); 71 } 72} 73
Downloadable files
Connection Diagram
Connection Diagram
Comments
Only logged in users can leave comments
Techinc1510
0 Followers
•0 Projects
26
0