极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 13778|回复: 0

就大神指导一下

[复制链接]
发表于 2018-5-2 14:00:45 | 显示全部楼层 |阅读模式
我最近做了一个RC522和Arduino相连的系统,功能就是读取卡的信息,为什么一直不成功啊,参照的之前看的一篇。
#include <SPI.h>
#include <MFRC522.h>

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

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

}
void loop()
{
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial())
  {
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++)
  {
     Serial.print(mfrc522.uid.uidByte < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte, HEX);
     content.concat(String(mfrc522.uid.uidByte < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte, HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "BD 31 15 2B") //change here the UID of the card/cards that you want to give access
  {
    Serial.println("Authorized access");
    Serial.println();
    delay(3000);
  }

else   {
    Serial.println(" Access denied");
    delay(3000);
  }
}
为什么复制过去显示什么uidByte【10】有歧义啊,无助
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-19 18:31 , Processed in 0.040619 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表