3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Password Lock with Arduino

Password Lock with Arduino
This instructable will show you how to make a pass-code lock system using the Arduino Mega board.
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



 
Remove these adsRemove these ads by Signing Up
 

Step 1Wire the LCD to the Arduino

Wire the LCD to the Arduino
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! :)
« Previous StepDownload PDFView All StepsNext Step »
12 comments
Mar 8, 2012. 9:11 PMroachburn says:
Thank you for this awesome instructable! I managed to use this with an Uno by driving the lcd with a 74hc595 shift register.
I used LiquidCrystal_SR.h Library which can be found here:

https://bitbucket.org/fmalpartida/new-liquidcrystal/overview

Also check out this post for more info on the shift register Library:

http://arduino.cc/forum/index.php/topic,90526.0.html


Mar 8, 2012. 10:07 PMroachburn says:

#include <Keypad.h>

#include <LiquidCrystal_SR.h>
Password password = Password( "4321" );
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3',},
  {'4','5','6',},
  {'7','8','9',},
  {'*','0',' ',}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {5, 6, 7, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 10, 11}; //connect to the column pinouts of the keypad
const int buttonPin = 12;
int buttonState = 0;

#define  DATAPIN  2
#define  CLOCKPIN 4
#define  STROBEPIN 3
#define  MAXCOLUMNS  16
#define  MAXLINES  2
#define ledPin 13
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
LiquidCrystal_SR lcd(DATAPIN, CLOCKPIN, STROBEPIN);

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  // set up the LCD's number of rows and columns:
  lcd.begin(MAXCOLUMNS, MAXLINES);
  digitalWrite(ledPin, LOW);
Serial.begin(9600);
keypad.addEventListener(keypadEvent); //add an event listener for this keypad
keypad.setDebounceTime(250);

 


void loop(){
keypad.getKey();
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
lcd.clear();
}
}
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
lcd.print(eKey);
switch (eKey){
case ' ': guessPassword(); break;
default:
password.append(eKey);
}
}}

void guessPassword(){
if (password.evaluate()){
digitalWrite(ledPin,HIGH); //activates garaged door relay
delay(500);
digitalWrite(ledPin,LOW); //turns off door relay after .5 sec
lcd.print("VALID PASSWORD "); //
password.reset(); //resets password after correct entry
delay(600);
lcd.print("Welcome");
delay(2000);
lcd.clear();
}


else{
digitalWrite(ledPin,LOW);
lcd.print("INVALID PASSWORD ");
password.reset(); //resets password after INCORRECT entry
delay(600);
lcd.clear();
}
}


Apr 19, 2012. 3:02 PMfekrheusa says:
I get an error when I run this code. the error is: 'Password' does not name a type
Dec 23, 2011. 11:38 AMDaniel Deacon says:
I haven't had time to look through the whole thing, however I see a floor how do I exit the room once I shut the door? is there some sort of button?
Dec 23, 2011. 2:06 PMDaniel Deacon says:
ok thanks, how would i put a button in the code? well done on your project btw! :)
Sep 19, 2011. 11:11 PMTECHMASTERJOE says:
you can use a arduino uno with not a lot more work just shift in the keypad and or shift out the lcd
try it sometime
i have my uno driving 644 pins (leds)
2X 20x4 lcd's
2 keypads
and about 10 buttons all over the house
Aug 13, 2011. 5:59 PMjackneil says:
would it be possible to modify this instructructable to work with a arduino Duemilanove if using say http://www.instructables.com/id/How-to-add-more-Outputs-to-your-Microcontroller/

Jul 23, 2011. 10:15 AMvishalapr says:
Awesome I never knew we could do this with an arduino! Very Very Very well done on this instructable!!!!!!!!!!!!!!!!!!!

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
14
Followers
3
Author:razvan_iycdi(My LMR page)