Password access with arduino by razvan_iycdi
Featured
248369_214759141892259_100000745240706_692276_4885192_n.jpg
254458_214759105225596_100000745240706_692275_6801652_n.jpg
DSC00029.JPG
~~ The complete kit for this tutorial is now for sale at www.razvantech.com   Get one! ~~

This instructable will show you how to make a pass-code lock system using the Arduino Mega board.
Whenyou type the right code, an LED lights up an the servo moves to open a lock.
What you will need:
--->one Arduino Mega (the arduino uno or duemilianove does not have enough digital pins for this project)
--->one LCD module
--->one Keypad
--->one Battery pack (or you can use the USB cable and PC power)
--->one 10K Ohm potentiometer
--->four 10K Ohm resistors
---> Breadboard
---> hookup wire
--->one servo
 
Remove these adsRemove these ads by Signing Up

Step 1: Wire the LCD to the Arduino

252437_214759195225587_100000745240706_692277_397784_n.jpg
DSC00027.JPG
DSC00028.JPG
The LCD module has 16 pins.
First of all, connect pins 1 and 16 of the LCD to the ground rail on the Breadboard
Then connect pins 2 and 15 of the LCD to the +5v rail on the breadboard
Now connect the ground rail(should be blue) of the breadboard to a ground pin on the Arduino;
Connect the +5v rail of the breadboard(this one is red) to one of the +5v pins on the Arduino board.

Now comes the contrast potentiometer which has to be connected to pin 3 of the LCD.
The potentiometer will have 3 pins. Take the middle pin and connect it to pin 3 of the arduino with hookup wire. Connect the othere two pins one to +5v and the other to GND(ground). The order does not matter.

Now let's do a test: power up the arduino. The LCD should light up. If it does then Great! If the LCD does not light up then turn off the power and check the wires.

Never change, move, or take out wires from the circuit board when the Arduino is powered up. You may permanently damage the Arduino.

If the light works rotate the potentiometer all the way to the right and all the way to the left until you see 2 rows of black squares. That's the contrast.

Now take out the power and let's hook up the LCD to the Arduino with the signal wires so we can display something on it.
Ready? Let's go!

Connect the pins as follows:
LCD Pin 4 --> Arduino Pin 2
LCD Pin 5 --> Arduino Pin 3
LCD Pin 6 --> Arduino Pin 4
LCD Pin 11 --> Arduino Pin 9
LCD Pin 12 --> Arduino Pin 10
LCD Pin 13 --> Arduino Pin 11
LCD Pin 14 --> Arduino Pin 12

And that should do it for the LCD circuit.
A test code for the the LCD: temporary.

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(2,3,4,9,10,11,12);

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}

void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}




Copy and paste it in an arduino environment window, make sure you have the board and serial port set correct and click UPLOAD after you plug in the usb with the arduino.
You will see the TX and RX led's blinking, that means the code is going to the arduino.
push the reset botton once on the arduino, tune the contrast, and you should see Hello World displayed.
Congratulations! You've got the LCD working! :) 
Swishercutter says: Sep 20, 2011. 6:07 PM
You might be able to modify this for the Uno/duemilanove if you use a 2x16 serial LCD...they only have one data wire, plus you can exclude the liquidcrystal.h because you simply use serial print.
taufique_ says: Jan 23, 2013. 11:55 AM
"...yte colPins[COLS] = {28, 27, 26}; //connect to the column pinouts of the keypad
const int buttonPin = 7;
int buttonState = 0; ....."

how does the arduino know when i am done entering my password and press # to 'enter' the system? it seems like a condition check is applied to Pin no 7 of the arduino board. I couldn't find anything attached to pin 7 of arduino...could you please look into it and confirm? I am assuming there is a typo in the code.
razvan_iycdi (author) says: Feb 26, 2013. 9:27 PM
Hey, here's how it works:
The keypad is set up so that there is a space instead of a '#'
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3',},
{'4','5','6',},
{'7','8','9',},
{'*','0',' ',}
};

then, when the Arduino reads what you write, it knows when you finished typing your password because you press the # key at the end:

switch (eKey){
case ' ': guessPassword(); break;
default:
password.append(eKey);
}

That bit of the code basically says: "Okay, so if the key that you press just sends me a white space, I will perform guessPassword(), which checks to see if your password is correct."

I hope that helps. Let me know if you need any more info.
taufique_ says: Jan 23, 2013. 10:46 AM
thank you for such an awesome instructable :)
razvan_iycdi (author) says: Feb 26, 2013. 9:15 PM
Thanks for checking it out. I hope I'll have time in the near future to make some more.
yinyangxD says: Aug 26, 2012. 12:50 PM
Sir, is it possible to display only asterisk as password? uhmm..encrypting the password being inputted by a user, uhm,,how can we do this? thank you
razvan_iycdi (author) says: Oct 9, 2012. 3:03 PM
Yes, just change the lcd.print(key) to lcd.print("*").
lhakim2 says: Jul 15, 2012. 7:01 PM
helo. i would like to request the circuit schematics. email me at luqmansemidin@gmail.com . thanks in advance :)
bond815 says: Dec 28, 2011. 1:29 PM
I went to verify the final code and got these errors, can you help?:


In file included from sketch_dec28a.cpp:1:
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Password/Password.h:33:22: error: WProgram.h: No such file or directory
In file included from sketch_dec28a.cpp:1:
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Password/Password.h:61: error: 'byte' does not name a type
In file included from sketch_dec28a.cpp:3:
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:50: error: 'byte' does not name a type
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:51: error: 'byte' does not name a type
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:63: error: 'byte' has not been declared
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:63: error: 'byte' has not been declared
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:63: error: 'byte' has not been declared
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:63: error: 'byte' has not been declared
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:78: error: ISO C++ forbids declaration of 'byte' with no type
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:78: error: expected ';' before '*' token
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:79: error: ISO C++ forbids declaration of 'byte' with no type
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:79: error: expected ';' before '*' token
sketch_dec28a:24: error: no matching function for call to 'Keypad::Keypad(char*, byte [4], byte [3], const byte&, const byte&)'
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:63: note: candidates are: Keypad::Keypad(char*, int*, int*, int, int)
C:\Documents and Settings\Michael\My Documents\Arduino\arduino-1.0-windows[1]\arduino-1.0\libraries\Keypad/Keypad.h:57: note: Keypad::Keypad(const Keypad&)
razvan_iycdi (author) says: Dec 28, 2011. 2:10 PM
You do not have the libraries where they are supposed to be. The error message is telling you that it can't find the libraries.

bond815 says: Jan 2, 2012. 12:30 PM
I have the libraries in the same library folder where all my other projects are.
razvan_iycdi (author) says: Jan 2, 2012. 1:16 PM
are you using mac or windows?
bond815 says: Jan 3, 2012. 5:33 AM
Windows XP
razvan_iycdi (author) says: Jan 3, 2012. 8:37 AM
[... here's what they say on the Arduino webpage...]

If you're using one of these libraries, you need to install it first. To do so, download the library and unzip it. It should be in a folder of its own, and will typically contain at least two files, one with a .h suffix and one with a .cpp suffix. Open your Arduino sketchbook folder. If there is already a folder there called libraries, place the library folder in there. If not, create a folder called libraries in the sketchbook folder, and drop the library folder in there. Then re-start the Arduino programming environment, and you should see your new library in the Sketch > Import Library menu.

http://www.arduino.cc/en/Reference/Libraries
Daniel Deacon says: Dec 30, 2011. 8:53 PM
How do i add the libarys i extracted them to arduino/libarys? 2 folders but not working
bond815 says: Nov 29, 2011. 1:00 PM
I can't get the LCD to show two rows of black squares. Any ideas?
razvan_iycdi (author) says: Nov 29, 2011. 1:20 PM
Hi there!
That's most likely a problem with your contrast potentiometer. If the potentiometer does not work, you may have not wired it right or maybe it is not 10KOhm. Try using a 10kohm resistor and lcd.print() something to see if it works.

Good luck!
msun2 says: Oct 23, 2011. 11:50 PM
Maybe it is good if you try to find out by asking direct and visited the campus in question. So that everything will be much clearer.pellet for sale
jmeyers56 says: Aug 21, 2011. 7:51 AM
I built something similar for my cs160 final. I didn't have the money for the LCD, keypad, or servo, so mine was just a bunch of buttons on a breadboard with LEDs. I would love to dig out my Arduino stuff and build one of these again though.
razvan_iycdi (author) says: Aug 21, 2011. 8:08 AM
Great!
etrenis says: Jun 30, 2011. 9:49 PM
Any way you can comment on what or where you got your two breadboards and what kind of servo your using?
razvan_iycdi (author) says: Jul 1, 2011. 8:42 AM
I've got three breadboards on there:
-a small one for the keypad
-a medium one for the LCD, potentiometer, and also as a bus
-a large one for experimenting
-the servo is an RC plane servo. The same one I used on the hovercraft.

Of course if you follow the connection layout you can use solderable PCB's and make a more durable and permanent circuit. But make your first try and tests on the solderless breadboards. You can also get theese from radioshack (except for the servo). Go to the orange hyperlinks and check those out. And, good luck on your future projects! :)
etrenis says: Jul 9, 2011. 9:47 PM
Any specific PCB or website that would be good to get PCB's from?
razvan_iycdi (author) says: Jul 9, 2011. 10:46 PM
Sure.
I put the links in the comment (the orange words are hyperlinks ) :) go there and you'll find everything you need for your robotics/electronix projects.
The main webpage is www.robotshop.com ... It's a great website.
I hope you'll find what you need and if you need any further help don't hesitate to ask. I'll be happy to help you.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!