Skip to main content

Arduino password protected door lock system

It is a password protected door lock project using arduino


Press # for clear then press the password ( in my case it is 1234)
and press * (star) for confirm.
now servo motor on and door lock will open .after 5 sec it will automatically close.



Parts need-

arduino uno
4x4 Matrix  keyboard
servo motor
jumper wire
power bank or battery for power supply
bread board
normal door lock
resistor 220 ohms


Connection -

key pad pin            Arduino digital pin
   
      1             to              9  
      2             to              8
      3             to              7
      4             to              6
      5             to              5
      6             to              4
      7             to              3
       8            to              2


green led to arduino digital pin 11

red led to arduino digital pin 12

led ground via 220 ohom resistor

servo signal to arduino digital pin 13


                        Connection Diagram






Arduino code--







#include <Password.h> //http://playground.arduino.cc/uploads/Code/Password.zip //tells to use password library
#include <Keypad.h> //http://www.arduino.cc/playground/uploads/Code/Keypad.zip  //tells to use keypad library
#include <Servo.h> //tells to use servo library


Servo myservo; //declares servo
Password password = Password( "1234" ); //password to unlock, can be changed

const byte ROWS = 4; // Four rows
const byte COLS = 4; // 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] = { 9, 8, 7, 6 };// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 5, 4, 3 };


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

void setup(){
  Serial.begin(9600);
  Serial.write(254);
  Serial.write(0x01);
  delay(200); 
  pinMode(11, OUTPUT);  //green light
  pinMode(12, OUTPUT);  //red light
  myservo.attach(13); //servo on digital pin 13//servo
  keypad.addEventListener(keypadEvent); //add an event listener for this keypad
  }

void loop(){
  keypad.getKey();
  myservo.write(0);
  }
  //take care of some special events
  void keypadEvent(KeypadEvent eKey){
  switch (keypad.getState()){
  case PRESSED:
  
  Serial.print("Enter:");
  Serial.println(eKey);
  delay(10);
  
  Serial.write(254);
  
  switch (eKey){
    case '*': checkPassword(); delay(1); break;
    
    case '#': password.reset(); delay(1); break;
    
     default: password.append(eKey); delay(1);
}
}
}
void checkPassword(){
  
if (password.evaluate()){  //if password is right open
    
    Serial.println("Accepted");
    Serial.write(254);delay(10);
    //Add code to run if it works
    myservo.write(150); //deg
    
        digitalWrite(11, HIGH);//turn on
    delay(5000); //wait 5 seconds
    digitalWrite(11, LOW);// turn off
    
    
}else{
    Serial.println("Denied"); //if passwords wrong keep locked
    Serial.write(254);delay(10);
    //add code to run if it did not work
    myservo.write(0);
    digitalWrite(12, HIGH); //turn on
    delay(500); //wait 5 seconds
    digitalWrite(12, LOW);//turn off
    
}
}

Comments

Post a Comment

Popular posts from this blog

how to make 4x4x4 led cube using arduino

To make 4x4x4 led cube using arduino you need arduino uno or arduino nano 3.0

parts list -


Arduino uno or nano
Resistor 100 ohom x4
wire
vero board ( doted or line )

header male   L shaped

cardboard

& LED 64 piece defuse led any colour


Total making process  described in this video




Connection to arduino-



Download Arduino code

How to Decode any IR remote ( TV,DVD,AC any other)

Decoding IR remote

Using this tutorial you can decode any Ir remote Hex code.and we can apply it our project also like home automation,robot control etc.

You need-

Arduino Uno or any other arduino board

TSOP 1738 or 1838

small bread board

jumper wire

& for test a LED


At first you have to add a library ( Download from here)


after download unzip it & paste folder to arduino library folder




connect IR sensor to arduino like above  Schematic


Now upload first code to arduino

First code--

#include <IRremote.h>

int IRpin = 8;
IRrecv irrecv(IRpin);
decode_results results;


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}  
void loop() 

{   
  if (irrecv.decode(&results)) 
    {
     Serial.println(results.value); // Print the Serial 'results.value'
      delay(10);

     irrecv.resume();   // Receive the next value
    }
}    



After this press any key on remote ,Hex code will show on serial monitor

copy hex code of any key in your choice


Now upload sec…

How to control light or fan using any IR remote (IC 4017)

using  this easy circuit you can use any IR remote like TV,DVD player to turn on & off

Parts List -

IC - CD 4017
IC - 7805 ( 5v regulator)

transistor - BC 548 B
                  BC 558

capacitor - 1000 mfd /16 v
                   100 mfd /16v

                      0.1um

resistor - 330 ohom x2
               1k,33ohm,220k

IR sensor TSOP 1738 or TSOP 1838

Diode   -  1N4007

Realy 6v


vero board,wire,




Circuit Diagram --

Pin out of transistor ,IC, Relay & IR sensor




                                                     You tube video ---