Advertisement
kinga20

Untitled

Jun 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. /*
  2. *
  3. * All the resources for this project: https://www.hackster.io/Aritro
  4. * Modified by Aritro Mukherjee
  5. * RFID authorized access or access denied code NO LCD
  6. *
  7. */
  8.  
  9. #include <SPI.h>
  10. #include <MFRC522.h>
  11.  
  12. #define SS_PIN 10
  13. #define RST_PIN 9
  14. MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
  15.  
  16. void setup()
  17. {
  18. Serial.begin(9600); // Initiate a serial communication
  19. SPI.begin(); // Initiate SPI bus
  20. mfrc522.PCD_Init(); // Initiate MFRC522
  21. Serial.println("Approximate your card to the reader...");
  22. Serial.println();
  23.  
  24. }
  25. void loop()
  26. {
  27. // Look for new cards
  28. if ( ! mfrc522.PICC_IsNewCardPresent())
  29. {
  30. return;
  31. }
  32. // Select one of the cards
  33. if ( ! mfrc522.PICC_ReadCardSerial())
  34. {
  35. return;
  36. }
  37. //Show UID on serial monitor
  38. Serial.print("UID tag :");
  39. String content= "";
  40. byte letter;
  41. for (byte i = 0; i < mfrc522.uid.size; i++)
  42. {
  43. Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
  44. Serial.print(mfrc522.uid.uidByte[i], HEX);
  45. content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
  46. content.concat(String(mfrc522.uid.uidByte[i], HEX));
  47. }
  48. Serial.println();
  49. Serial.print("Message : ");
  50. content.toUpperCase();
  51. if (content.substring(1) == "45 C3 23 C3") //change here the UID of the card/cards that you want to give access
  52. {
  53. Serial.println("Authorized access");
  54. Serial.println();
  55. delay(3000);
  56. }
  57.  
  58. else {
  59. Serial.println(" Access denied");
  60. delay(3000);
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement