Introduction: Scure Lock With RFID Tag and PIN

Picture of Scure Lock With RFID Tag and PIN

You checked in a hotel and given a RFID tag to access your room. If you lost your card and someone else had the lost card can access to your room. Wouldn't it be more secure if another piece of information like PIN is required to open the door?

I have made a simple system using Arduino, RFID reader, display panel and keypad just to demonstrate that. Here I use a LED as a metaphor of a door lock.

Step 1: The Components

Picture of The Components

Follow are the list of hardware and software component required to build this project:

Arduino UNO & Genuino UNO



Generic Keypad

Jumper wires (generic)

Male/Female Jumper Wires

Arduino IDE

Some RFID/NFC cards

Step 2: Connect the LCD Display

Connect to LCD-LCM1602 IIC according to the following:

LCD GND pin to GND

LCD VCC pin to 5V

LCD SDA pin to analog 4

LCD SCL pin to analog 5

Please note that I am not able to find a 4-pin LCD-LCM1602 IIC item in fritzing, you need to match the above connection accordingly.

Step 3: Connect the LED

Connect the LED to pin 7.

Step 4: Connect the Keypad

Connect keypad according to the following configuration:

Keypad pin 1 to digital pin 5

Keypad pin 1 to digital pin 4

Keypad pin 1 to digital pin 3

Keypad pin 1 to digital pin 2

Keypad pin 1 to digital pin 14

Keypad pin 1 to digital pin 15

Keypad pin 1 to digital pin 16

Keypad pin 1 to digital pin 17

Please note that digital pins 14, 15, 16,and 17 are extended by analog pins A0, A1, A2, and A3.

Step 5: Connect the RFID Card Reader

I am using the RFID-RC522 card reader. Connect the card reader to match the following configuration:

RFID pin Reset to pin 9

RFID pin SS/SDA to pin 10

RFID pin MOSI to pin 11

RFID pin MISO to pin 12

RFID pin SCK to pin 13

RFID pin GND to pin GND

RFID pin 3.3V to pin 3.3V

Step 6: The Schema

Picture of The Schema

This is the final schema.

Step 7: The Codes

Setup the cards, user names and passwords.

// init paralle arrays
byte knownCards[NR_KNOWN_CARDS][CARD_SIZE] = {
{0x93, 0x47, 0xe0, 0x00},
{0xe5, 0xa2, 0x9c, 0x2c}
char name[NR_KNOWN_CARDS][10] = {
char password[NR_KNOWN_CARDS][5] = {

Setup the keypad.

// define for keypad
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
byte rowPins[ROWS] = {5, 4, 3, 2};
byte colPins[COLS] = {14, 15, 16, 17};

Setup the LCD display.

// define for lcd
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

The main event loop.

void loop() {

Step 8: Demo: a Welcome Prompt

Picture of Demo: a Welcome Prompt

A welcome greeting!

Step 9: Demo: Tag a RFID Card and Enter PIN

Picture of Demo: Tag a RFID Card and Enter PIN

Tag a RFID card to the reader. You will see a greeting and be asked to key in a PIN. If you key in a wrong PIN or do not manage to key in a PIN within 30 seconds, it will show the welcome prompt again.

Step 10: Demo: Door Unlocked

Picture of Demo: Door Unlocked

If you key in a correct PIN, the red LED light will light up indicating that door is unlocked.


ErnestoN2 (author)2018-01-04

hi, i have a doubt: what kind of data should be written in the tag? I save the name "James" as plain text but it give the message "user not found"

ssaassaa (author)2017-07-23

hi.i can not undrestand that where should i write rfid tag id.please help me and answer me to my email

WierdDuDe16 (author)2017-01-09

having problems with the code, getting the error: 'digitalPinToBitMask' was not declared in this scope, i don't really know how to fix it, would love to get a bit of help with it

AlfredV5 (author)2016-12-01

can you give me the complete code please!! here's my email A huge thanks!!

wesee (author)AlfredV52016-12-01

see my earlier comment below.

ElectroSchool (author)2016-06-27

please can you give me the complete code

TranNguyen (author)ElectroSchool2016-11-21

can you give me the complete code, please!

wesee (author)TranNguyen2016-11-21

the code is at the end of step 7: secure_lock_rfid_pin.c

TranNguyen (author)wesee2016-11-21

thankyou very much

About This Instructable




More by wesee:You Can Fly a Piece of PaperScure Lock With RFID Tag and PINWeather Dashboard using MKR1000 and Losant
Add instructable to: