Monday, August 6, 2018

https://www.instructables.com/id/Arduino-door-lock-with-password/

ARDUINO DOOR LOCK WITH PASSWORD

Picture of Arduino Door Lock With Password

Step 1: PARTS & TOOLS

Picture of PARTS & TOOLS
Picture of PARTS & TOOLS
Picture of PARTS & TOOLS
Picture of PARTS & TOOLS
For this project I used:
* 4x4 matrix keypad, can also use 3x4( http://www.ebay.com/itm/4-x-4-Matrix-Array-16-Key-... )
The tools you are going to need:
* Soldering iron
* Soldering paste
* Soldering tin
* Plier

Step 2: Schematic

Picture of Schematic
Follow the schematic.

Step 3: Solder the Connectors

Picture of Solder the Connectors
Picture of Solder the Connectors
Picture of Solder the Connectors
3 More Images
Solder he connections for the Arduino, kaypad and servo. When you are soldering the connection for the keypad and the servo try not to have it in a place where the programing port on the Arduino UNO touches your soldered places, I did that once and I almost ended up destroying my Arduino because the 5v and the GND got connected together when they touched the programing port.

Step 4: Soldering

Picture of Soldering
Picture of Soldering
Picture of Soldering
Picture of Soldering
3 More Images
Solder the LEDs, resistors and the wires for them, than solder the rest of the wires, try to cut your wires so that they fit nice and smooth on the PCB like shown in the photos.

Step 5: The Door Lock

Picture of The Door Lock
I mounted my servo on an aluminum plate with an simple lock. unfortunately I did not take any photos when making this but hopefully you will understand how to make it by the photo, its really easy.

Step 6: CODE

Download the code and import libraries. You need to download the 3 Arduino libraries if you don't have them.
* password.h
* keypad.h
* servo.h
THANKS FOR VIEWING!
Ifyou like this project than go check out my channel for more cool projects :)
If you have any questions or tips than post them in the comments.

#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( "0000" ); //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 9 //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
    
}
}

No comments:

Post a Comment

สรุปงานที่ 5 Internet of Things (IoT)

Internet of Things (IoT) คืออะไร           Internet of Things (IoT) คือ  "อินเตอร์เน็ตในทุกสิ่ง" หมายถึง การที่อุปกรณ์ต่างๆ ส...