try to implement rfid
This commit is contained in:
30
project/rfid/rfid.c
Normal file
30
project/rfid/rfid.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <unistd.h>
|
||||
#include "MFRC522.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
MFRC522 mfrc;
|
||||
|
||||
mfrc.PCD_Init();
|
||||
|
||||
while(1)
|
||||
{
|
||||
if(!mfrc.PICC_IsNewCardPresent())
|
||||
continue;
|
||||
if(!mfrc.PICC_ReadCardSerial())
|
||||
continue;
|
||||
|
||||
for(byte i = 0; i < mfrc.uid.size; ++i){
|
||||
if(mfrc.uid.uidByte[i] < 0x10){
|
||||
printf(" 0");
|
||||
printf("%X",mfrc.uid.uidByte[i]);
|
||||
} else {
|
||||
printf(" ");
|
||||
printf("%X", mfrc.uid.uidByte[i]);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
usleep(1000*1000);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user