- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用带有 NFC 扩展板的 arduino 板来解锁我的车门。
开发板:Arduino UNO Rev 3NFC 扩展板:Seeed Studio v2.0b
因此,当 NFC 标签存在时,信号会将伺服器旋转 180 度以解锁门。目前的问题是我只希望一个 NFC 标签能够解锁/锁定门,而不是任意一个。
目前任何 NFC 标签都可以转动 Helm 机。
有谁知道调用哪个函数只返回 NFC 标签的 UID,然后可以将其与已知的 NFC 标签进行比较。
http://www.seeedstudio.com/wiki/NFC_Shield_V2.0
#include <SPI.h>
#include "PN532_SPI.h"
#include "PN532.h"
#include "NfcAdapter.h"
String const myUID = "1B B3 C6 EF"; // replace this UID with your NFC tag's UID
int const greenLedPin = 3; // green led used for correct key notification
int const redLedPin = 4; // red led used for incorrect key notification
PN532_SPI interface(SPI, 10); // create a SPI interface for the shield with the SPI CS terminal at digital pin 10
NfcAdapter nfc = NfcAdapter(interface); // create an NFC adapter object
void setup(void) {
Serial.begin(115200); // start serial comm
Serial.println("NDEF Reader");
nfc.begin(); // begin NFC comm
// make LED pins outputs
pinMode(greenLedPin,OUTPUT);
pinMode(redLedPin,OUTPUT);
// turn off the LEDs
digitalWrite(greenLedPin,LOW);
digitalWrite(redLedPin,LOW);
}
void loop(void) {
Serial.println("Scanning...");
if (nfc.tagPresent()) // check if an NFC tag is present on the antenna area
{
NfcTag tag = nfc.read(); // read the NFC tag
String scannedUID = tag.getUidString(); // get the NFC tag's UID
if( myUID.compareTo(scannedUID) == 0) // compare the NFC tag's UID with the correct tag's UID (a match exists when compareTo returns 0)
{
// The correct NFC tag was used
Serial.println("Correct Key");
// Blink the green LED and make sure the RED led is off
digitalWrite(greenLedPin,HIGH);
digitalWrite(redLedPin,LOW);
delay(500);
digitalWrite(greenLedPin,LOW);
delay(500);
digitalWrite(greenLedPin,HIGH);
delay(500);
digitalWrite(greenLedPin,LOW);
// put your here to trigger the unlocking mechanism (e.g. motor, transducer)
}else{
// an incorrect NFC tag was used
Serial.println("Incorrect key");
// blink the red LED and make sure the green LED is off
digitalWrite(greenLedPin,LOW);
digitalWrite(redLedPin,HIGH);
delay(500);
digitalWrite(redLedPin,LOW);
delay(500);
digitalWrite(redLedPin,HIGH);
delay(500);
digitalWrite(redLedPin,LOW);
// DO NOT UNLOCK! an incorrect NFC tag was used.
// put your code here to trigger an alarm (e.g. buzzard, speaker) or do something else
}
}
delay(2000);
}
此代码有效。
最佳答案
您表明您当前正在检测到任何标签后解锁。因此您必须已经正在轮询标签。如果您使用的是原始 seeedstudio 库,则可以使用 inListPassiveTarget()
方法或(如 commesan 所示)readPassiveTargetID()
对任何被动目标执行轮询> 方法。
虽然 inListPassiveTarget()
仅返回一个 bool 值,指示是否存在任何目标,但 readPassiveTargetID()
方法为您提供了一组配置参数,还允许您检索防冲突标识符(例如 ISO 14443 A 类的 UID):
bool PN532::readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength, uint16_t timeout);
你可以使用这样的方法:
uint8_t uid[16] = { 0 };
uint8_t uidLen = 0;
if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLen)) {
// uid will now contain uidLen bytes of the anti-collision identifier
}
如果您想轮询 ISO 14443 Type A 以外的其他卡,可以使用以下定义代替 PN532_MIFARE_ISO14443A
:
// ISO 14443 Type B
#define PN532_BAUD_ISO14443B (0x03)
// FeliCa 212 kbps
#define PN532_BAUD_FELICA212 (0x01)
// FeliCa 424 kbps
#define PN532_BAUD_FELICA424 (0x02)
// Jewel Tag (NFC Forum Type 1)
#define PN532_BAUD_JEWEL (0x04)
最后,我关于使用标签的 UID 进行访问控制的通常注意事项:不要这样做!在许多现有系统中,这已被证明是一个非常糟糕的主意。请参阅这些帖子以获取更多信息:
关于Arduino NFC门解锁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23446584/
我是 NFC 新手,我想将支持 NFC 的安卓手机作为 NFC 标签,并使用 NFC 阅读器读取其数据。如果您能建议我已经构建的用于发送数据的 NFC 应用程序或我应该使用哪种 NFC 读取器硬件,那
我使用ACR122U工具验证Mifare 1K NFC标签时总是失败,但是我可以用Android手机读写这个标签。 ACR122U Load Authentication Keys 90 00 6
我对 NFC 标准的概述有一些问题。 我所知道的是: ISO/IEC 14443是感应卡的标准,使用 RFID 作为通信协议(protocol); ISO/IEC 18092 (NFCIP-1) 是
我正在尝试实现一个基于通用 NFC 标签的授权系统。我想解决的问题之一是标签克隆。我读过一些文献,通过使用在制造过程中写在标签上的只读标签 ID 来确保标签的真实性。此 ID 由所有者签名并写在标签上
我想为使用 RFID 实现多项功能的系统提案指定设备。它可能会在未来扩展到包括交易,所以我正在努力寻找合适的技术来使用。 计划是使用被动卡。 HF/NFC 卡/读卡器以相同的频率运行,但它们可以互换使
我有一个 ACR122U 阅读器,可以读取很多标签,但不能读取 ICODE SLIX SL2S2002 标签。为什么会这样?我已经在移动设备上尝试过该标签,它被识别出来了。 最佳答案 ICODE SL
NFC Host Card Emulation mode摆脱了本地安全元件 (SE),并通过利用存储在云中的 SE 来促进支付,使用 cooperation几个参与方,例如商家、服务、提供商、发卡机构
Mifare (S50) 1K NFC 卡有 16 个扇区,每个扇区有 4 个 block ,每个 block 保存 16 字节数据。 每个扇区的最后一个 block 是扇区尾部,其中 KeyA 和
我创建的系统存在一些问题。 在登录屏幕等特定页面上,我接受 NFC 卡刷卡以读取 ID 并让用户登录 但是,当用户在未编码 NFC 的页面上扫描卡时,Android 设备会自动最小化我的应用程序并显示
我正在尝试使用 NFC 从血糖仪读取数据,目前在 Android 上,还没有尝试过 iOS(没有带 NFC 的手机)。 我正在使用 react-native-nfc-manager 作为库和它附带的示
这个问题专门针对 MIFARE Ultralight C/EV1,或 MIFARE DESFire EV1,甚至 NTAG 卡。我想实现一个 token 系统,这样每次普通用户读取其中一张卡片时,他们
考虑一名员工使用 NFC 安卓设备通过读取固定在墙上的非接触式 javacard 来报告他的位置,每个人都可以访问。 员工用智能手机扫描javacard,只发送时间戳 非接触式 javacard 接收
有没有办法让 NFC 应用程序读取标签,而不是可以在手机上下载的所有其他应用程序? 通常,如果有多个应用程序可以读取给定标签,系统会提示用户打开哪个应用程序。我想跳过这一步,让我的应用程序自动打开。
我想让我的安卓设备充当 NFC 标签。是否可以使用 NFC 设备作为 NFC 标签?我怎样才能做到这一点?我已经完成了读/写标签,设备之间的光束数据。 最佳答案 这可能是可行的,具体取决于您的 NFC
如果我有 NFC 读取器/写入器设备,我能否让它检测我的支持 NFC 的 Android 手机,以便我可以将数据从我的手机传输到该设备?我在 Stackoverflow 上找到了一些与卡模拟相关的链接
我在 SO 上看到很多关于 NFC 的问题,我遇到的最接近的问题是 Can an Android NFC phone act as an NFC tag? 然而,这个问题是一年多前提出的,当时 Gal
我有一台搭载 Android 4.2 的 Android 平板电脑。此平板电脑没有 NFC 硬件。但是我有一个外部 USB 读卡器:ACR 1252U , 带有 Android library .不幸
据我目前了解,NFC 手机将充当 NFC 阅读器,从 NFC 标签读取数据。现在我的问题是,我们可以改变这个吗?我们能否让 Android NFC 手机充当 NFC 读取器从中获取数据的标签? 感谢您
我被搜索了有关 NFC SIM 卡的信息,发现 such explanations关于他们在这里和那里: For those who want to use near field communicat
Core NFC 是否适用于 iPad? 综上所述,iPad does have NFC chips ,但 Core NFC documentation不说它支持它。 Note Reading NFC
我是一名优秀的程序员,十分优秀!