目前,各個(gè)地方正在推廣有關(guān)非接觸式操作的任何事情,以降低感染病毒的風(fēng)險(xiǎn)。這讓我質(zhì)疑生活在經(jīng)濟(jì)和健康問題的 COVID 世界中的兩個(gè)重要方面。
使用這個(gè)想法,我制作了一個(gè) RFID 設(shè)備,它為它的串行監(jiān)視器(本質(zhì)上是計(jì)算機(jī))提供信息。只有有限數(shù)量的卡可以解鎖系統(tǒng),在此過程中,Arduino 會(huì)檢測 RFID 卡的唯一標(biāo)識(shí)號(hào) (UID)。在串行監(jiān)視器上,它會(huì)就 UID 號(hào)向用戶提供建議,然后通過提供授權(quán)或拒絕訪問來描述情況。所有這些都是在 Arduino 的能力下完成的,它可以在有限的時(shí)間內(nèi)處理這個(gè)處理。
此項(xiàng)目的步驟:
庫下載
這是整個(gè)項(xiàng)目中最重要的一步,沒有這個(gè),代碼將無法工作,電路將無法工作,就像我在你的項(xiàng)目失敗之前所說的那樣。
該庫可使用此鏈接獲得,其中包含需要提取的 ZIP 文件:https ://github.com/miguelbalboa/rfid
提取文件后,您將放入一個(gè)已經(jīng) Arduino 文件夾,這意味著該庫現(xiàn)在位于您下載的 Arduino 應(yīng)用程序中。
訪問此項(xiàng)目時(shí),您需要通過轉(zhuǎn)到文件 ? 示例 ? 自定義庫來檢查它,以確保您確認(rèn)它在那里。確保單擊這些選項(xiàng)將其插入 Arduino。
設(shè)置電路
我提供了一個(gè)根據(jù)引腳接線的簡單表格,這是操作 RFID 閱讀器所必需的。
將庫上傳到 ARDUINO
如前所示,示例類別,在單擊作為自定義庫一部分的 MFRC522 后,您將選擇“DumpInfo”。該術(shù)語指的是如何處理大量信息。這對(duì)于閱讀器必須做出多產(chǎn)判斷的 RFID 來說是必需的。
選擇 DumpInfo 后,您需要轉(zhuǎn)到串行監(jiān)視器 (Ctrl+Shift+M),它會(huì)要求您掃描 RFID 卡。
掃描后,串口監(jiān)視器會(huì)提示用戶卡 UID,如下圖所示。
記得注明這張卡的 UID,這將在后面的代碼中使用。
現(xiàn)在您將上傳正在設(shè)置的代碼。請(qǐng)記住更改它所說的 UID 號(hào),我將在軟件部分對(duì)此進(jìn)行評(píng)論。如果您不更改,您將始終顯示訪問被拒絕。
粘貼代碼后,必須打開串行監(jiān)視器,然后在掃描正確的卡和錯(cuò)誤的卡后,您將看到如下圖所示的信息。
偽代碼
此偽代碼旨在幫助您理解,如果我在軟件部分提供的 Arduino 代碼中的某些術(shù)語,您不會(huì)對(duì)定義產(chǎn)生任何疑問的語言中的代碼。
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
流程圖
串行監(jiān)視器的代碼:
#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
+關(guān)注
關(guān)注
391文章
6448瀏覽量
242473 -
掃描儀
+關(guān)注
關(guān)注
2文章
436瀏覽量
68447
發(fā)布評(píng)論請(qǐng)先 登錄
評(píng)論