SHARE
TWEET

Untitled

a guest Feb 20th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SPI.h>
  2. #include <MFRC522.h>
  3. #include <Servo.h>
  4. #include <LiquidCrystal_I2C.h>
  5. LiquidCrystal_I2C screen (0x3f, 16, 2);
  6. #define SS_PIN 10
  7. #define RST_PIN 9
  8. MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
  9. Servo Tahm;
  10.  
  11. const int trigPin = 6;
  12. const int echoPin = 7;
  13. long duration;
  14. int distanceCm, distanceInch;
  15.  
  16.  
  17.  
  18.  
  19. void setup()
  20. {
  21.   pinMode(trigPin, OUTPUT);
  22.   pinMode(echoPin, INPUT);
  23.   screen.begin();
  24.   screen.setBacklight((uint8_t)1);
  25.   Serial.begin(9600);   // Initiate a serial communication
  26.   SPI.begin();      // Initiate  SPI bus
  27.   mfrc522.PCD_Init();   // Initiate MFRC522
  28.   Serial.println("Searching for a card.");
  29.   Serial.println();
  30.   Tahm.attach (3);
  31.   Tahm.write (179);
  32.   msg();
  33. }
  34. void msg() {
  35.   screen.clear();
  36.   screen.print("  where ");
  37.   screen.setCursor (0,1);
  38.   screen.print ("    ya at");
  39. }
  40. void loop()
  41. {
  42.   // Look for new cards
  43.   if ( ! mfrc522.PICC_IsNewCardPresent())
  44.   {
  45.     return;
  46.   }
  47.   // Select one of the cards
  48.   if ( ! mfrc522.PICC_ReadCardSerial())
  49.   {
  50.     return;
  51.   }
  52.   //Show UID on serial monitor
  53.   Serial.print("UID tag :");
  54.   String content= "";
  55.   byte letter;
  56.   for (byte i = 0; i < mfrc522.uid.size; i++)
  57.   {
  58.      Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
  59.      Serial.print(mfrc522.uid.uidByte[i], HEX);
  60.      content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
  61.      content.concat(String(mfrc522.uid.uidByte[i], HEX));
  62.   }
  63.   Serial.println();
  64.   Serial.print("Message : ");
  65.   content.toUpperCase();
  66.   if (content.substring(1) == "2E AE DD 89") //change here the UID of the card/cards that you want to give access
  67.   {
  68.     Serial.println("ye come on in");
  69.     Serial.println();
  70.     screen.clear();
  71.     screen.print (" u good.");
  72.     Tahm.write (0);
  73.     delay (5000);
  74.     Tahm.write (179);
  75.     msg();
  76.   }
  77.  
  78.  else   {
  79.     Serial.println("Adios");
  80.     screen.clear();
  81.     screen.print (" authorities are ");
  82.     screen.setCursor (0,1);
  83.   screen.print ("on their way");
  84.     delay(5000);
  85.     msg();
  86.   }
  87. }
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