Browse code

Update Login at PC with Arduino + RFID

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

... ...
@@ -1,11 +1,13 @@
1 1
 // --------------------------------------------------------
2
-// Masterpasswort .  Anmelden mit RFID-ROM Chip TOWITEC + Arduino Micro.
3
-//--------start USB-Keyboard 
2
+//  Login on PC with RFID-ROM Chip TOWITEC + Arduino Micro. A password-store
3
+//--------------------------------------------------------
4
+//--------start Arduino as USB-Keyboard 
4 5
 #include "Keyboard.h"
5 6
 int i;
6 7
 int z = 0;
7 8
 int key[5];
8 9
 String keyvalue;
10
+int bytes_from_RFID = 5;
9 11
 void setup()
10 12
 {
11 13
 Serial1.begin(9600); // start serial to RFID reader
... ...
@@ -19,13 +21,13 @@ if (Serial1.available() > 0)
19 21
 i = Serial1.read();
20 22
 z ++;
21 23
 // -------------6 = 5+1(bytes)
22
-if (z <6)
24
+if (z < (bytes_from_RFID + 1) )
23 25
   {
24 26
 Serial.print(i, DEC);
25 27
 Serial.print(" ");
26 28
 key[z] =i;
27 29
 // -----------------5 bytes from RFID
28
-if (z == 5)
30
+if (z == bytes_from_RFID)
29 31
    {
30 32
  Serial.println();
31 33
  Serial1.end();
... ...
@@ -35,12 +37,12 @@ if (z == 5)
35 37
  keyvalue = (keyvalue + key[3]);
36 38
  keyvalue = (keyvalue + key[4]);
37 39
  keyvalue = (keyvalue + key[5]);
38
- if (keyvalue == "5 bytes from RFID")
40
+ if (keyvalue == "Put in the 5 bytes provided by serial monitor without spaces!")
39 41
    {
40
-
42
+//------- \n after password means Newline or ENTER
41 43
  Keyboard.print("topsecretPW\n");
42 44
    }
43
-// -----------------5 Sekundensperre
45
+// -----------------5 Seconds lock
44 46
  delay(5000);
45 47
 --------------------Thats not nice but it works.
46 48
  Serial1.begin(9600);