段软w 发表于 2021-6-18 11:18
void printDec(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Ser ...
这里面都是byte呀,哪来的int ?#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 rfid(SS_PIN, RST_PIN); //创建MFRC522实例
MFRC522::MIFARE_Key key;
byte nuidPICC[4];
void setup() {
Serial.begin(9600);
SPI.begin(); //初始化 SPI 总线
rfid.PCD_Init(); //初始化 MFRC522 卡
for (byte i = 0; i < 6; i++) {
key.keyByte[i] = 0xFF;
}
}
void loop() {
if(!rfid.PICC_IsNewCardPresent())
return;
if(!rfid.PICC_ReadCardSerial())
return;
for (byte i = 0; i < 4; i++) {
nuidPICC[i] = rfid.uid.uidByte[i];
}
Serial.print(F("Dev1:"));
printDec(rfid.uid.uidByte, rfid.uid.size);
//暂停PICC
rfid.PICC_HaltA();
//暂停PCD上的加密
rfid.PCD_StopCrypto1();
}
void printDec(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i] < 0x10 ? "0" : "");
Serial.print(buffer[i], DEC);//十进制
}
Serial.println(" ");
}
|