標(biāo)題: 求RFID庫函數(shù),MFRC522的Arduino庫函數(shù) [打印本頁]

作者: 會好的    時間: 2020-4-13 12:01
標(biāo)題: 求RFID庫函數(shù),MFRC522的Arduino庫函數(shù)
制作門禁系統(tǒng),但是看不懂程序,沒找到MFEC522的庫函數(shù),還請各位大佬能留下

作者: dfghjkljhgf    時間: 2021-6-7 00:32
areduino   ide里面有
作者: 七禾頁    時間: 2021-6-7 12:29
論壇里應(yīng)該有
作者: angmall    時間: 2021-6-7 13:56
MFRC522的Arduino函數(shù)
  1. /*
  2. *
  3. * All the resources for this project:
  4. * Modified by Aritro Mukherjee
  5. *
  6. *
  7. */

  8. #include <SPI.h>
  9. #include <MFRC522.h>

  10. #define SS_PIN 10
  11. #define RST_PIN 9
  12. MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

  13. void setup()
  14. {
  15.   Serial.begin(9600);   // Initiate a serial communication
  16.   SPI.begin();      // Initiate  SPI bus
  17.   mfrc522.PCD_Init();   // Initiate MFRC522
  18.   Serial.println("Approximate your card to the reader...");
  19.   Serial.println();

  20. }
  21. void loop()
  22. {
  23.   // Look for new cards
  24.   if ( ! mfrc522.PICC_IsNewCardPresent())
  25.   {
  26.     return;
  27.   }
  28.   // Select one of the cards
  29.   if ( ! mfrc522.PICC_ReadCardSerial())
  30.   {
  31.     return;
  32.   }
  33.   //Show UID on serial monitor
  34.   Serial.print("UID tag :");
  35.   String content= "";
  36.   byte letter;
  37.   for (byte i = 0; i < mfrc522.uid.size; i++)
  38.   {
  39.      Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
  40.      Serial.print(mfrc522.uid.uidByte[i], HEX);
  41.      content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
  42.      content.concat(String(mfrc522.uid.uidByte[i], HEX));
  43.   }
  44.   Serial.println();
  45.   Serial.print("Message : ");
  46.   content.toUpperCase();
  47.   if (content.substring(1) == "BD 31 15 2B") //change here the UID of the card/cards that you want to give access
  48.   {
  49.     Serial.println("Authorized access");
  50.     Serial.println();
  51.     delay(3000);
  52.   }

  53. else   {
  54.     Serial.println(" Access denied");
  55.     delay(3000);
  56.   }
  57. }
復(fù)制代碼



MFRC522-1.4.8.zip

1.16 MB, 下載次數(shù): 18






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1