projects:rfid-revbank-username

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
projects:rfid-revbank-username [2021/05/30 19:56]
ron [TO DO]
projects:rfid-revbank-username [2021/10/20 16:31] (current)
marc
Line 11: Line 11:
  
  
-// Include Libraries +  // Include Libraries 
-#include "Arduino.h" +  #include "Arduino.h" 
-#include "RFID.h" +  #include "RFID.h" 
-#include "Keyboard.h"+  #include "Keyboard.h" 
 +   
 +   
 +  // Pin Definitions 
 +  #define RFID_PIN_RST 
 +  #define RFID_PIN_SDA  10
  
  
-// Pin Definitions 
-#define RFID_PIN_RST  2 
-#define RFID_PIN_SDA  10 
  
 +  // Global variables and defines
 +  
 +  // object initialization
 +  RFID rfid(RFID_PIN_SDA,RFID_PIN_RST);
 +  
 +  
 +  // define vars for testing menu
 +  const int timeout = 10000;       //define timeout of 10 sec
 +  char menuOption = 0;
 +  long time0;
 +  long cooldown = 0;
 +  int greenLed = 6;
 +  int redLed = 7;
  
 +  // Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
 +  void setup() 
 +  {
 +        // Setup Serial which is useful for debugging
 +        // Use the Serial Monitor to view printed messages
 +        Serial.begin(9600);
 +        //while (!Serial) ; // wait for serial port to connect. Needed for native USB
 +        Serial.println("start");
 +        pinMode(greenLed,OUTPUT);
 +         pinMode(redLed,OUTPUT);
 +        //initialize RFID module
 +        rfid.init();
 +        //rfid.PCD_SetAntennaGain(rfid.RxGain_max);
 +       //menuOption = menu();
 +        delay(5000);
 +        Keyboard.begin();
 +  }
  
-// Global variables and defines +  // Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop. 
- +  void loop()  
-// object initialization +  {
-RFID rfid(RFID_PIN_SDA,RFID_PIN_RST); +
- +
- +
-// define vars for testing menu +
-const int timeout = 10000;       //define timeout of 10 sec +
-char menuOption = 0; +
-long time0; +
-long cooldown = 0; +
-int greenLed = 6; +
-int redLed = 7; +
- +
-// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity. +
-void setup()  +
-+
-    // Setup Serial which is useful for debugging +
-    // Use the Serial Monitor to view printed messages +
-    Serial.begin(9600); +
-    //while (!Serial) ; // wait for serial port to connect. Needed for native USB +
-    Serial.println("start"); +
-    pinMode(greenLed,OUTPUT); +
-    pinMode(redLed,OUTPUT); +
-    //initialize RFID module +
-    rfid.init(); +
-    //rfid.PCD_SetAntennaGain(rfid.RxGain_max); +
-    //menuOption = menu(); +
-    delay(5000); +
-    Keyboard.begin(); +
-+
- +
-// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop. +
-void loop()  +
-{+
          
          
-    //if(menuOption == '1') { +        //if(menuOption == '1') { 
-    // RFID Card Reader - RC522 - Test Code +        // RFID Card Reader - RC522 - Test Code  
-    //Read RFID tag if present +      //Read RFID tag if present 
-    String rfidtag = rfid.readTag(); +       String rfidtag = rfid.readTag(); 
-    //print the tag to serial monitor if one was discovered +      //print the tag to serial monitor if one was discovered 
-    if((cooldown+3000) < millis()) +      if((cooldown+3000) < millis()) 
-    +      
-      rfid.printTag(rfidtag); +        rfid.printTag(rfidtag); 
-      ledState("off"); +        ledState("off"); 
-        if(rfidtag == "[badge-ID]")//[badge-number] +          if(rfidtag == "[badge-ID]")//[badge-number] 
-        +          
-          cooldown = millis(); +            cooldown = millis(); 
-          Keyboard.print("[revbank-username]"); +            Keyboard.print("[revbank-username]"); 
-          Keyboard.press(KEY_RETURN); +             Keyboard.press(KEY_RETURN); 
-          Keyboard.releaseAll(); +              Keyboard.releaseAll(); 
-          ledState("green"); +              ledState("green"); 
-        } else if(rfidtag == "[badge-ID]") //[badge-number] +            } else if(rfidtag == "[badge-ID]") //[badge-number] 
-        +          
-          cooldown = millis(); +             cooldown = millis(); 
-          Keyboard.print("[revbank-username]"); +              Keyboard.print("[revbank-username]"); 
-          Keyboard.press(KEY_RETURN); +              Keyboard.press(KEY_RETURN); 
-          Keyboard.releaseAll(); +              Keyboard.releaseAll(); 
-          ledState("green"); +            ledState("green"); 
-        } else +          } else 
-        +          
-          ledState("red"); +            ledState("red"); 
-        +          
-    +      
-     +         
-}+  }
  
  
-void ledState(char color+  void ledState(char color)
-+
-  if(color == "green")+
   {   {
-    digitalWrite(greenLed,HIGH); +      if(color == "green"
-    digitalWrite(redLed,LOW); +      { 
-  } else if(color == "red"+        digitalWrite(greenLed,HIGH); 
-  +      digitalWrite(redLed,LOW); 
-    digitalWrite(redLed,HIGH); +    } else if(color == "red"
-    digitalWrite(greenLed,LOW); +    
-  } else +      digitalWrite(redLed,HIGH); 
-  +       digitalWrite(greenLed,LOW); 
-    digitalWrite(redLed,LOW); +    } else 
-    digitalWrite(greenLed,LOW);+    
 +      digitalWrite(redLed,LOW); 
 +      digitalWrite(greenLed,LOW); 
 +    } 
   }   }
-} 
  
  
  • projects/rfid-revbank-username.txt
  • Last modified: 2021/10/20 16:31
  • by marc