目前,各個地方正在推廣有關非接觸式操作的任何事情,以降低感染病毒的風險。這讓我質疑生活在經濟和健康問題的 COVID 世界中的兩個重要方面。
使用這個想法,我制作了一個 RFID 設備,它為它的串行監視器(本質上是計算機)提供信息。只有有限數量的卡可以解鎖系統,在此過程中,Arduino 會檢測 RFID 卡的唯一標識號 (UID)。在串行監視器上,它會就 UID 號向用戶提供建議,然后通過提供授權或拒絕訪問來描述情況。所有這些都是在 Arduino 的能力下完成的,它可以在有限的時間內處理這個處理。
此項目的步驟:
庫下載
這是整個項目中最重要的一步,沒有這個,代碼將無法工作,電路將無法工作,就像我在你的項目失敗之前所說的那樣。
該庫可使用此鏈接獲得,其中包含需要提取的 ZIP 文件:https ://github.com/miguelbalboa/rfid
提取文件后,您將放入一個已經 Arduino 文件夾,這意味著該庫現在位于您下載的 Arduino 應用程序中。
訪問此項目時,您需要通過轉到文件 ? 示例 ? 自定義庫來檢查它,以確保您確認它在那里。確保單擊這些選項將其插入 Arduino。
設置電路
我提供了一個根據引腳接線的簡單表格,這是操作 RFID 閱讀器所必需的。
將庫上傳到 ARDUINO
如前所示,示例類別,在單擊作為自定義庫一部分的 MFRC522 后,您將選擇“DumpInfo”。該術語指的是如何處理大量信息。這對于閱讀器必須做出多產判斷的 RFID 來說是必需的。
選擇 DumpInfo 后,您需要轉到串行監視器 (Ctrl+Shift+M),它會要求您掃描 RFID 卡。
掃描后,串口監視器會提示用戶卡 UID,如下圖所示。
記得注明這張卡的 UID,這將在后面的代碼中使用。
現在您將上傳正在設置的代碼。請記住更改它所說的 UID 號,我將在軟件部分對此進行評論。如果您不更改,您將始終顯示訪問被拒絕。
粘貼代碼后,必須打開串行監視器,然后在掃描正確的卡和錯誤的卡后,您將看到如下圖所示的信息。
偽代碼
此偽代碼旨在幫助您理解,如果我在軟件部分提供的 Arduino 代碼中的某些術語,您不會對定義產生任何疑問的語言中的代碼。
Include Serial Peripheral Interface to sketch
Include external example, in this case the RFID Reader example
Give a constant value to the serial input pin
To make sure that the RFID resets after being used
To make the MFRC522 an instance
“While true”
Set the speed of communication between Arduino and serial monitor at 9600 bits per second.
Initiate the (BUS)
Initate MFRC522
Print “Approximate your card to the reader…”);
Print new line
Loop
If new card is present, turn on for limited time
Identify Card Serial
Print “UID tag :”)
Response required
Print (“Message : “)
If the UID is the specific UID number
Print “Authorised Access”)
With delay for 3 seconds
otherwise
Print “Access denied”
Then delay for 3 seconds
流程圖
串行監視器的代碼:
#include
#include
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup()
{
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
Serial.println("Approximate your card to the reader...");
Serial.println();
}
void loop()
{
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)?
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "29 C2 07 5E") // Make sure you change this with your own UID number
{
Serial.println("Authorised access");
Serial.println();
delay(3000);
}
else {
Serial.println(" Access denied");
delay(3000);
}
-
RFID
+關注
關注
390文章
6333瀏覽量
240287 -
掃描儀
+關注
關注
2文章
432瀏覽量
68252
發布評論請先 登錄
相關推薦
評論