Browse code

Create Login with Arduino + RFID

Stefan Höhn authored on12/01/2017 15:08:10 • GitHub committed on12/01/2017 15:08:10
Showing1 changed files

1 1
new file mode 100644
... ...
@@ -0,0 +1,53 @@
1
+// --------------------------------------------------------
2
+// Masterpasswort .  Anmelden mit RFID-ROM Chip TOWITEC + Arduino Micro.
3
+--------start USB-Keyboard 
4
+#include "Keyboard.h"
5
+int i;
6
+int z = 0;
7
+int key[5];
8
+String keyvalue;
9
+void setup()
10
+{
11
+Serial1.begin(9600); // start serial to RFID reader
12
+Serial.begin(9600); // start serial to PC
13
+Keyboard.begin();
14
+}
15
+void loop()
16
+{
17
+if (Serial1.available() > 0)
18
+ {
19
+i = Serial1.read();
20
+z ++;
21
+// -------------6 = 5+1(bytes)
22
+if (z <6)
23
+  {
24
+Serial.print(i, DEC);
25
+Serial.print(" ");
26
+key[z] =i;
27
+// -----------------5 bytes from RFID
28
+if (z == 5)
29
+   {
30
+ Serial.println();
31
+ Serial1.end();
32
+
33
+ keyvalue = (key[1] );
34
+ keyvalue = (keyvalue + key[2]);
35
+ keyvalue = (keyvalue + key[3]);
36
+ keyvalue = (keyvalue + key[4]);
37
+ keyvalue = (keyvalue + key[5]);
38
+ if (keyvalue == "5 bytes from RFID")
39
+   {
40
+
41
+ Keyboard.print("topsecretPW\n");
42
+   }
43
+// -----------------5 Sekundensperre
44
+ delay(5000);
45
+--------------------Thats not nice but it works.
46
+ Serial1.begin(9600);
47
+ 
48
+z=0;
49
+   }
50
+  }
51
+ }
52
+}
53
+// ---------------------------------