Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- //
- //
- //
- //
- #include <SPI.h>
- #include <MFRC522.h>
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- #include <Servo.h>
- #define RST_PIN 9 // Configurable, see typical pin layout above
- #define SS_PIN 10 // Configurable, see typical pin layout above
- MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
- /* Set your new UID here! */
- #define NEW_UID {0xDE, 0xAD, 0xBE, 0xEF}
- MFRC522::MIFARE_Key key;
- LiquidCrystal_I2C lcd(0x3F, 16, 2);
- Servo servito;
- void setup() {
- Serial.begin(9600); // Initialize serial communications with the PC
- while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
- SPI.begin(); // Init SPI bus
- mfrc522.PCD_Init(); // Init MFRC522 card
- Serial.println(F("Warning: this example overwrites the UID of your UID changeable card, use with care!"));
- // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
- for (byte i = 0; i < 6; i++) {
- key.keyByte[i] = 0xFF;
- }
- {
- lcd.begin();
- lcd.setBacklight((uint8_t)1);
- lcd.print("Scan ID");
- lcd.setCursor(0,1);
- lcd.print("Card Please");
- delay(100);
- servito.attach(6);
- }
- }
- void loop() {
- // Look for new cards, and select one if present
- if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) {
- delay(50);
- return;
- }
- // Now a card is selected. The UID and SAK is in mfrc522.uid.
- Serial.println(F("Card UID:"));
- for (byte i = 0; i < mfrc522.uid.size; i++)
- {
- Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
- Serial.print(mfrc522.uid.uidByte[i], HEX);
- }
- Serial.println();
- lcd.clear();
- if (mfrc522.uid.uidByte[0] == 0xF2 && mfrc522.uid.uidByte[1] == 0x92 && mfrc522.uid.uidByte[2] == 0xC1 && mfrc522.uid.uidByte[3] == 0x49)
- {
- lcd.print("Authorized");
- lcd.setCursor(0,1);
- lcd.print("Access");
- Serial.println("Authorized Access");
- servito.write(179);
- delay(1000);
- servito.write(0);
- }
- else {
- lcd.print("Denied Access");
- Serial.println("Denied Access");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement