forked from villinte/RPi-RFID
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRead.cpp
56 lines (46 loc) · 862 Bytes
/
Read.cpp
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
47
48
49
50
51
52
53
54
55
56
#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);
break;
}
byte buffer[4] = { 0x00 };
buffer[0] = 0x9E;
buffer[1] = 0x3B;
buffer[2] = 0x63;
buffer[3] = 0x61;
mfrc.MIFARE_OpenUidBackdoor(true);
mfrc.MIFARE_SetUid(buffer, byte(4), true);
return 0;
}