Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <MFRC522.h>
- #define RST_PIN 9
- #define SS_PIN 10
- MFRC522 mfrc522(SS_PIN, RST_PIN);
- void setup() {
- serial.begin(9600);
- while (!Serial);
- SPI.begin();
- mfrc522.PCD_Init();
- delay(4);
- mfrc522.PCD_DumpVersionToSerial();
- Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
- }
- void loop() {
- if ( ! mfrc522.PICC_IsNewCardPresent() ) {
- return;
- }
- if ( ! mfrc522.PICC_ReadCardSerial() ) {
- return;
- }
- String uid = "";
- for (byte i = 0; i < mfrc522.uid.size; i++) {
- uid.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
- uid.concat(String(mfrc522.uid.uidByte[i], HEX));
- }
- uid.toUpperCase();
- Serial.println(uid);
- delay (3000);
- if (uid.substring(1) == "F5 7E 7E 63") //Replace this with the HEX value that your card has
- {
- Serial.println("ID Accepted");
- }
- else
- {
- Serial.println("ID Denied");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement