forked from miguelbalboa/rfid
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathRead.cpp
More file actions
46 lines (38 loc) · 658 Bytes
/
Read.cpp
File metadata and controls
46 lines (38 loc) · 658 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
void delay(int ms){
#ifdef WIN32
Sleep(ms);
#else
usleep(ms*1000);
#endif
}
#include "MFRC522.h"
int main(){
MFRC522 mfrc;
mfrc.PCD_Init();
while(1){
// Look for a card
if(!mfrc.PICC_IsNewCardPresent())
continue;
if( !mfrc.PICC_ReadCardSerial())
continue;
// Print UID
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");
delay(1000);
}
return 0;
}