-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArduino_Code.ino
More file actions
107 lines (85 loc) · 1.78 KB
/
Copy pathArduino_Code.ino
File metadata and controls
107 lines (85 loc) · 1.78 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
uint8_t buf[8] = {
0 }; /* Keyboard report buffer */
int cardCount = 0;
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
delay(200);
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
}
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
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
content.toUpperCase();
if (content.substring(1) == "E6 F4 94 F4" , "B3 C9 2C 83" , "F3 68 47 0C" , "43 55 51 0C" , "06 7D 4A F6" , "06 E8 5B F6" ) //change here the UID of the card/cards that you want to give access
{
delay(50);
buf[0] = 0;
buf[2] = 0xE3; // Win Key
buf[3] = 0x0F; // letter L
Serial.write(buf, 8);
releaseKey();
delay(200);
buf[0] = 0;
buf[2] = 0x04; // letter A
Serial.write(buf, 8);
releaseKey();
delay(50);
buf[0] = 0;
buf[2] = 0x05; // letter B
Serial.write(buf, 8);
releaseKey();
delay(50);
buf[0] = 0;
buf[2] = 0x06; // letter C
Serial.write(buf, 8);
releaseKey();
delay(50);
buf[0] = 0;
buf[2] = 0x07; // letter D
Serial.write(buf, 8);
releaseKey();
cardCount++;
}
else {
return;
}
if(cardCount= 1 ){
delay(50);
buf[0] = 0;
buf[2] = 0x28; // letter Enter
Serial.write(buf, 8);
releaseKey();
cardCount--;
}
}
void releaseKey()
{
buf[0] = 0;
buf[2] = 0;
buf[3] = 0;
Serial.write(buf, 8); // Release key
}