Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. //Programa : RFID - Controle de Acesso leitor RFID
  2. //Autor : FILIPEFLOP
  3.  
  4. #include <SPI.h>
  5. #include <MFRC522.h>
  6.  
  7. #define SS_PIN 10
  8. #define RST_PIN 9
  9. MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
  10.  
  11. char st[20];
  12.  
  13. void setup()
  14. {
  15. Serial.begin(9600);
  16.  
  17. SPI.begin(); // Inicia SPI bus
  18. mfrc522.PCD_Init(); // Inicia MFRC522
  19. Serial.println("Aproxime o seu cartao do leitor...");
  20. Serial.println();
  21. //Define o número de colunas e linhas do LCD:
  22. mensageminicial();
  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. //Mostra UID na serial
  38. Serial.print("UID da tag :");
  39. String conteudo= "";
  40. byte letra;
  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. conteudo.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
  46. conteudo.concat(String(mfrc522.uid.uidByte[i], HEX));
  47. }
  48. Serial.println();
  49. Serial.print("Mensagem : ");
  50. conteudo.toUpperCase();
  51. if (conteudo.substring(1) == "ED 78 03 CA") //UID 1 - Chaveiro
  52. {
  53. Serial.println("Ola FILIPEFLOP !");
  54. Serial.println();
  55. delay(3000);
  56. mensageminicial();
  57. }
  58.  
  59. if (conteudo.substring(1) == "BD 9B 06 7D") //UID 2 - Cartao
  60. {
  61. Serial.println("Ola Cartao !");
  62. Serial.println();
  63. delay(3000);
  64. mensageminicial();
  65. }
  66. }
  67.  
  68. void mensageminicial()
  69. {
  70. Serial.println();
  71. Serial.print("Aproxime seu cartão");
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement