daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //
  3. //
  4. //
  5. //
  6. #include <SPI.h>
  7. #include <MFRC522.h>
  8. #include <Wire.h>
  9. #include <LiquidCrystal_I2C.h>
  10. #include <Servo.h>
  11.  
  12. #define RST_PIN   9     // Configurable, see typical pin layout above
  13. #define SS_PIN    10    // Configurable, see typical pin layout above
  14.  
  15. MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance
  16.  
  17. /* Set your new UID here! */
  18. #define NEW_UID {0xDE, 0xAD, 0xBE, 0xEF}
  19.  
  20. MFRC522::MIFARE_Key key;
  21.  
  22. LiquidCrystal_I2C lcd(0x3F, 16, 2);
  23.  
  24. Servo servito;
  25.  
  26.  
  27.  
  28. void setup() {
  29.   Serial.begin(9600);  // Initialize serial communications with the PC
  30.   while (!Serial);     // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
  31.   SPI.begin();         // Init SPI bus
  32.   mfrc522.PCD_Init();  // Init MFRC522 card
  33.   Serial.println(F("Warning: this example overwrites the UID of your UID changeable card, use with care!"));
  34.  
  35.   // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
  36.   for (byte i = 0; i < 6; i++) {
  37.     key.keyByte[i] = 0xFF;
  38.   }
  39.  
  40. {
  41.   lcd.begin();
  42.   lcd.setBacklight((uint8_t)1);
  43.  
  44.   lcd.print("Scan ID");
  45.  
  46.   lcd.setCursor(0,1);
  47.   lcd.print("Card Please");
  48.   delay(100);
  49.  
  50.   servito.attach(6);
  51.  
  52. }
  53. }
  54.  
  55. void loop() {
  56.  
  57.   // Look for new cards, and select one if present
  58.   if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) {
  59.     delay(50);
  60.     return;
  61.   }
  62.  
  63.   // Now a card is selected. The UID and SAK is in mfrc522.uid.
  64.  
  65.  Serial.println(F("Card UID:"));
  66.   for (byte i = 0; i < mfrc522.uid.size; i++)
  67.   {
  68.     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
  69.     Serial.print(mfrc522.uid.uidByte[i], HEX);
  70.   }
  71.   Serial.println();
  72.  
  73.   lcd.clear();
  74. if  (mfrc522.uid.uidByte[0] == 0xF2 && mfrc522.uid.uidByte[1] == 0x92 && mfrc522.uid.uidByte[2] == 0xC1 && mfrc522.uid.uidByte[3] == 0x49)
  75. {
  76.   lcd.print("Authorized");
  77.   lcd.setCursor(0,1);
  78.   lcd.print("Access");
  79.   Serial.println("Authorized Access");
  80.   servito.write(179);
  81.   delay(1000);
  82.   servito.write(0);
  83.   }
  84.  
  85. else {
  86.   lcd.print("Denied Access");
  87.   Serial.println("Denied Access");
  88. }
  89. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top