Devices & Components
Arduino Uno Rev3
Breadboard (generic)
Resistor 220 ohm
5 mm LED: Green
5 mm LED: Red
Jumper wires (generic)
RFID reader (generic)
Software & Tools
Arduino IDE
Project description
Code
Code
c_cpp
Paste into your ide and change the uid.
1#include <SPI.h> 2#include <MFRC522.h> 3 4#define SS_PIN 10 5#define RST_PIN 9 6MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. 7 8void setup() 9{ 10 pinMode(4,OUTPUT); 11 pinMode(3,OUTPUT); 12 Serial.begin(9600); // Initiate a serial communication 13 SPI.begin(); // Initiate SPI bus 14 mfrc522.PCD_Init(); // Initiate MFRC522 15 Serial.println("Approximate your card to the reader..."); 16 Serial.println(); 17 18} 19void loop() 20{ 21 // Look for new cards 22 if ( ! mfrc522.PICC_IsNewCardPresent()) 23 { 24 return; 25 } 26 // Select one of the cards 27 if ( ! mfrc522.PICC_ReadCardSerial()) 28 { 29 return; 30 } 31 //Show UID on serial monitor 32 Serial.print("UID tag :"); 33 String content= ""; 34 byte letter; 35 for (byte i = 0; i < mfrc522.uid.size; i++) 36 { 37 Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); 38 Serial.print(mfrc522.uid.uidByte[i], HEX); 39 content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); 40 content.concat(String(mfrc522.uid.uidByte[i], HEX)); 41 } 42 Serial.println(); 43 Serial.print("Message : "); 44 content.toUpperCase(); 45 if (content.substring(1) == "53 F7 CE 18") //to find card uid go to the serial moniter, scan your card and copy uid into the section 46 47 { 48 digitalWrite(4,HIGH); 49 digitalWrite(3,LOW); 50 Serial.println("Authorized access"); 51 Serial.println(); 52 delay(3000); 53 } 54 55 else { 56 digitalWrite(4,LOW); 57 digitalWrite(3,HIGH); 58 Serial.println(" Access denied"); 59 delay(3000); 60 } 61}
Downloadable files
Schematics image
RFID schematic in the description. If not clear, connections are also in the description. :)
Schematics image

Schematics
Schematics, RFID reader in the description
Schematics
Schematics image
RFID schematic in the description. If not clear, connections are also in the description. :)
Schematics image

Schematics
Schematics, RFID reader in the description
Schematics
Comments
Only logged in users can leave comments