Security System and Access Control With Arduino and RFID

Introduction: Security System and Access Control With Arduino and RFID

I am 47 years old and I live in Brazil. I am a Telecommunication / Electronics Engineer. twenty y...

Security System and Access Control with Arduino and RFID

This project is an evolotuin of my first project called "Arduino - Security System and Access Control"
As you can see at the blog (sorry but this project still be in Portuguese).

Instead of using a matricial keyboard, to enter passwords and to allow access to a door or to drive an electronic device, now we will use a RFID (Radio Frequency Identifier Device).
We also will use a LCD Display with 20 character and 4 lines to show some messages from the system, besides a servo-motor to drive an mechanical device like (door's locks, turnstile, etc...).

The electronic device used  it is the MFRC522AN RFID (13.56MHz MiFare RC522AN with SPI communication) which can be easily found on electronics shop or on the internet sites at an affordable price.

Like this:

Step 1: Operation


Users will have cards or tags registered to access the system.
When approaching the card/tag to the RFID sensor (approximately 6 cm), the
serial number of this card/tag is detected and so compared with a serial number  that are recorded in the software or in a database on a memory card; if it is a registered serial number, the system will release the entry of this user. A green LED will be lit and some messages will be appearing  in the LCD display ( user recognition and user  welcome), besides that a servo will be drived to release a mechanical device.

Otherwise, the system does not release the user access, and a warning red LED will be lit  and will be showed a message on the LCD advising  the user to contact the account manager.
During this process of release or rejection of users, characteristics beeps will be played on a buzzer (just like a sound announcement).

See the explanatory video at the "Video and Picture" section.

Step 2: Stuff and Materials


1 x Arduino UNO, MEGA, Duemilanove ou Teensy, etc...
1 x RFID MFRC522AN (SPI communication)
1 x servo-motor 9g
1 x LCD 20x4 (I2C comunication)
1 x green LED
1 x red LED
2 x 220 Ohm reistor
1 x Buzzer
1 x Bread Board
wires and cables to the connection

Step 3: Device Interconnections


Interconnections from the RFID to the Arduino pins:
Reset     > Pin 5
SS           > Pin 10
MOSI      > Pin 11
MISO      > Pin 12
SCK       > Pin 13
Ground  > Ground
3.3v        > 3.3v

Interconnections from the LCD (I2C) to the Arduino pins:
GND > GND of the Arduino
VCC > +5V of the Arduino
SDA > A4 pin of the Arduino
SCL > A5 pin of the Arduino

Step 4: The Whole Project Interconnections

The whole project:

Remember that the LCD is a 20x4 display and the RFID is the MRFC522AN device.
The Buzzer and the servo motor are general purpose devices.

Step 5: Programming

The files were deposited in google drive, to access, you need to create your own account or ask me to share the file with you.

Below you have the Arduino's sketch, that should be placed in a folder with the same name of the file.

In the next link you have the file "pitches.h" it is necessary to play the musical notes and the sounds, it must be in the same folder of the Arduino sketch.


Get all files on GitHub:

Step 6: Videos and Pictures


This is a preliminary video, only to see the general operation of the system.

See on youtube:




  • Tiny Home Contest

    Tiny Home Contest
  • Water Contest

    Water Contest
  • Creative Misuse Contest

    Creative Misuse Contest

59 Discussions

The display is not displaying the message only black captions

good job mr

It doesn't work for me :(

Hello sir
I may use your code its super sir.
But myquestion is how to display a employees detail in LCD display ? What's it's code ? Plz sir share a link or code sir it's my project sir so soon you replay sir
Thanking for you are code

ask me in this email

Put the project name and I will send de details for you.

is the tutorial to save allowed tags in SD card posted already? great instructible

BIGDOG1971 halo,

thanks for posting, so help me.
overnight tried in sequence and a little editing on:
emaomos byte [5] = {0xDE, 0x1F, 0x47,0xC9,0x4F};
with HEX my tag, and managed to walk. and I want to adding a tag id in order to use his ID, respectively, if you can help how to code?
and for the future development of this program if it can be combined with a password keypad, with the picture when the id tag will bring up the program received a command to enter a password

Thank you in advance


in your sketch there is

byte emaomos[5] = {0xDE,0x1F,0x47,0xC9,0x4F}; // Marcelo Moraes (e+mao+mos)

Please explain to me about correlation between emaomos and 0xDE,0x1F,0x47,0xC9,0x4F ? How to translate that?

If i wanna use my name, let say WACHID how to type in sketch.

Thanks Sir,

1 reply

Mr Wachid,


byte emaomos[5] = {0xDE,0x1F,0x47,0xC9,0x4F}; // Marcelo Moraes (e+mao+mos)
// coloque aqui seus outros cartões permitidos

if not wrong to be edited or inserted tag HEX father, I happened overnight to try and succeed.

Marcelo how are you ? You talked in your previous posts, that you were developing a RFID Access Control with log , hows that coming?

Olá, obrigado pelo belo tutorial, mas eu coloquei o codigo aqui para rodar e deu erro, o que eu fiz de errado?

RFID_Simples.ino:35:21: error: pitches.h: No such file or directory

RFID_Simples:40: error: 'RFID' does not name a type

RFID_Simples:46: error: 'LiquidCrystal_I2C' does not name a type

RFID_Simples:52: error: 'NOTE_G4' was not declared in this scope

RFID_Simples:52: error: 'NOTE_A4' was not declared in this scope

RFID_Simples:52: error: 'NOTE_B4' was not declared in this scope

RFID_Simples:52: error: 'NOTE_A4' was not declared in this scope

RFID_Simples:52: error: 'NOTE_B4' was not declared in this scope

RFID_Simples:52: error: 'NOTE_C5' was not declared in this scope

RFID_Simples:54: error: 'NOTE_G2' was not declared in this scope

RFID_Simples:54: error: 'NOTE_F2' was not declared in this scope

RFID_Simples:54: error: 'NOTE_D2' was not declared in this scope

RFID_Simples.ino: In function 'void setup()':

RFID_Simples:70: error: 'lcd' was not declared in this scope

RFID_Simples:74: error: 'rfid' was not declared in this scope

RFID_Simples.ino: In function 'void loop()':

RFID_Simples:88: error: 'lcd' was not declared in this scope

RFID_Simples:94: error: 'rfid' was not declared in this scope

How can i use a relay instead of servo? What changes need to be done to sketch? Thanks

Sir,i am having trouble while installing library,can u please send me detailed procedure for installing rfid libraries and its original program to work...plz respond as soon as possible....Thankyou...plz email me at

Hi can i get the following file and can you share the file to and can you send or share it through my google drive . I really need the files for the arduino project and it is important to have them otherwise your arduino project that im testing out will not be complete. i will really appreciate if you send the files.







Hi Im new to arduino and im trying to make your project but the point is when i download the arduino code from your google drive i open it and see it is in a different language and when i try using google translate, i cant translate out the words. so can you upload anther arduino code for this project in english so i can download the english code from you.

how Muc power does the RC522 draw from the Arduino UNO. I thought it was limited to 50 ma at 3.3v any problems with this? Can you handle multiple tags?


I'm new to the arduino and programming. Would this be simple for me to setup? Instead of the servo I will be using a relay. I've tried a couple other script but cannot get them to work. Please let me know if this would work on the latest arduino... I will,order all parts.

how to adding new card, which has 4 byte and 7 byte?. in your code only using 4 byte. your answer will be very useful to me. please answer. or send me and email to :