Introduction: Access Control With Arduino + Keypad 4x4 + Servo (UPDATE)

Picture of Access Control With Arduino + Keypad 4x4 + Servo (UPDATE)
Hi guys, I bring a new instructable for arduino, the control access with password, 4x4 keypad and a servo.

We will use the Password and Keypad librarie for arduino, besides using the servo library, but this project can also be modified by changing the servo, a motor reley or motor stepper, or any other ideas ...

This project can be used in different cases, for doors, Servo action, etc.. Here is the link of the video on youtube to see how it works, then explain step for the armed : D

Step 1: The Parts for the Project

Picture of The Parts for the Project

We will need this parts for the proyect:

Arduino UNO or similar ($29.95)

Servo motor - Large ($12.95)

KEYPAD 4X4 (or similar) ($7.79)

Proto Board  ($9.58)

Breadborad jumper wire pack ($10.59)

Four resistor of 910 ohm

One resistor of 1k

Step 2: Preparing the Keypad

Picture of Preparing the Keypad

Well, now we must put the resistors,remember the potion of the pins of the keypad.

Output pins of keypad:

1 pin = col 1
2 pin = col 2
3 pin = col 3
4 pin = col 4

5 pin = row 1
6 pin = row 2
7 pin = row 3
8 pin = row 4

(look at the second image)

Now they must put three 910 ohm resistors on pin 1, 2 and 3 of the keypad, then put in the arduino digital pins of the NEXT form:

pins keypad  |  pins arduino
          1           |           8
          2           |           7
          3           |           6
          4           |           9        
          5           |           5
          6           |           4
          7           |           3
          8           |           2

Step 3: Preparing the Servo

Picture of Preparing the Servo

You need put the servo of the next form :

Step 4: Connecting the LEDs

Picture of Connecting the LEDs

You need put Accepted LED (green) and Denied LED (red) in this way:

Step 5: (UPDATE) and Now, the Programming

You need this libraries:

Password librarie

Keypad librarie

Well, this is the code for arduino, you only need to change that write in bold and put your password.

And this is my new instructable, enjoy it :D

¡ Good luck !


bugwr (author)2017-06-21


how do I use an electromagnetic lock for this project

uNKNoWND3 (author)2017-02-20

how to add 16x2 lcd
pleasse help me.. thanks

abdooooo (author)2017-02-03

i want to control 360 servo such that when you press A1 the srvo rotate 60 degrees and A2 it rotate 120 and so on
i tried using many codes but none of them is working probably
the code is this
#include <Keypad.h>

#include <Servo.h>

Servo myservo;

int pos = 0;

const byte ROWS = 4; //four rows

const byte COLS = 4; //four columns

//define the cymbols on the buttons of the keypads

char hexaKeys[ROWS][COLS] = {






byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad

byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad

Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){




void loop(){

int position;

char customKey = customKeypad.getKey();

if (customKey){




// myservo.write(pos);

myservo.write(60); // Tell servo to go to 90 degrees



PrashanthN6 (author)2017-01-31

Will u please tell me

PrashanthN6 (author)2017-01-31

Use of resitors in this project

abdooooo (author)2017-01-21

Hello, can i want to connect 2 continuous rotational servos with 4*4 keypad, the keypad determine the angle each servos goes to
could you help me with the code please?

harshil_kapadia (author)2016-11-12

its showing this error

what to do?

mohammad2314 (author)2016-10-25

hi , where is theschematic project

ilhama9 (author)2016-03-02

Can you give me a sketch of keypad 4x4?

kau_cinta_ku (author)ilhama92016-04-10

#include <Keypad.h>

const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to row pinouts
byte colPins[COLS] = {6, 7, 8, 9}; //connect to column pinouts

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {

void loop() {
char key = keypad.getKey();

if (key != NO_KEY) {

Raj Barhate (author)kau_cinta_ku2016-05-10

it is saying there is no keypad.h

JoãoS86 (author)Raj Barhate2016-05-14

you problably dont have that library installed... download that library... then go to arduino's folder and put the library inside a folder called libraries

MehmeteminP (author)2016-04-13


LindimV (author)2016-03-08

How does it work if i have a 3x4 keypad is it the same but instead of using 8 pins i use 7 ?

kau_cinta_ku (author)LindimV2016-04-10

you will have to redefine the keymap to fit your keypad

athomsen3 (author)2016-04-06

So if I want to make the arduino open a garage door when pushing the right password followed by "A" and turning on and off alarm by pushing the right password followed by "B". Can anyone help me do that. Thank you in advance

KeinToast (author)2016-03-10

Sup, i tried to make this for my own too but i have a small Problem. (First Project)

C:\Users\(Censored)\Desktop\Keypad_servo\keypad_password_servo_ v1.1\keypad_password_servo\keypad_password_servo.ino:5:23: fatal error: Password.h: No such file or directory

#include <Password.h>


compilation terminated.

exit status 1

Fehler beim Kompilieren. (German: Failure)

Can you help me?

zain siddiqui (author)2016-01-31

can somebody tell me what is the password?

i have me the circuit. but its not working without password

asmaasma (author)2015-11-30

i can't find the code plzz help me

ea. k made it! (author)2015-10-02

I made it... Thanks a lot

nyatuv (author)2013-04-13

can i use arduino mega?

GeorgeBgk (author)nyatuv2015-09-29

Of course, you can!

SavageO (author)2015-07-31


do we have to use the resistors for the keyboard?

GeorgeBgk (author)SavageO2015-09-29

No, keypad library uses internal pull up resistors

SavageO (author)2015-07-31

I cant get it working,when I enter the password and press A nothing happens

RIJO VADAKKAN made it! (author)2015-07-24


عامرا (author)2015-07-15

carl.cortesnazareth (author)2014-11-18

When I plug in my servo to my arduino it starts spinning without stopping. How do I fix this?


Shark123456 (author)2015-03-25

can somebody please copy and paste the code into the comment section? I can't seem to access the zip file. I would love to make this but without the code it kinda impossible

camilo.n1012 (author)Shark1234562015-03-25

Hi, you can download the file from this link:

zinedine (author)2015-01-26

Hi guy, I have just handmade a matrix keypad for arduino, I'll use that in control driver motor servo 250VAC. But it was noise when I put in the box a metal. It's mean it run, however I didn't pressed keypad. So how about I can filter noise?

camilo.n1012 (author)zinedine2015-01-26

Hi, i don't understand your question on the issue, if you can be more explicit to help I'd appreciate. Regards !

hisham.goda.92 (author)2015-01-25

@camilo.n1012 , please when i write #include <Keypad.h> , the keypad word be in black not in red , and when i upload the code , the arduino does not recognize the keypad , is there any solution for that ?

You may have problems with the address of the file, check in the folder "/ libraries" of Arduino IDE if the file.h is there. It should be in orange the code. If you follow the problem let me know and I give you another solution. Greetings !!

tornado.abood (author)2014-12-05

Where is the code of project ?

Hi, you can download the code from here:

masterji (author)camilo.n10122014-12-15

seem it cannot be found...can you please give the right link?

your help is much apreciated.thank you

camilo.n1012 (author)masterji2014-12-16

This is the new link:

Good Luck !

caserpsychocgo (author)2014-09-24

donde va el password como lo meto porque si lo dejo en letras negras me da error

Hola ! El pasword lo defines en el mismo archivo .ino, en la variable "Password password = Password( "your_password" );", ubicada en la linea 20 del codigo, de todos modos te dejo la imagen de muestra.
Saludos y éxito !

camilo.n1012 (author)2014-08-12

Sorry for not having answered the guys posts, but I had a problem with the mail.

The code already update, if they have more doubts, I can write to me mail or send a MP.

Regards !

hayes255 (author)2014-07-16

Camilo.n1012 the code needs to be updated

hayes255 (author)2014-07-15

I can't get the password librarie

kschwartz5 (author)2014-07-07

camilo.n1012, the code isn't updated and needs to be so that it will continue to work. Please update it soon.


mekaci89 (author)2014-06-06

The BYTE term seems to be invalid for Arduino 1.X

I am getting same error too. Please update this Instructable, thanks.

r.raj936 (author)2013-05-19

I made one of this kind and when I was testing there was a power failure and I had to be out till I got my spare keys.

Edward_ (author)2013-04-16

The BYTE term seems to be invalid for Arduino 1.X, what version did you use?
I'm trying to convert. Can you update this Instructable? or add updated code?

FarmerKJS (author)2013-01-23

could you use an ir remote insted of a keypad if possible a code too thanks.

matoran_nuparu (author)2012-12-13

Hi! Nice instructable! but the link to the password library doesn't work. here's correct:

About This Instructable




More by camilo.n1012:Control Access of Arduino YÚN with MySQL, PHP5 and PythonAccess control with Arduino + Keypad 4x4 + Servo (UPDATE)Save data of temperature and humidity on MySQL with Arduino Uno and Wifly
Add instructable to: