Security Vault Attempt 3.1 [Success]


I successfully rebuilt the locked box instructable project.

When the correct password was entered into the keypad the green LED light switched on and the servo turned 90 degrees to unlatch.



When the incorrect password or the clear key's ('#' or '*') were pressed the red LED switched on and the green LED was switched of. The servo turned 90 degrees in the opposite direction, to latch.



The video below shows the project working fully





When attempting this project again, I mainly followed the code instead of the circuit diagram because I wanted to ensure that the wires connected to my keypad were plugged into the correct pins on the Arduino board. I realised that if the pins numbers were not 100% the same as the code then the project was not going to work and therefore the hardware or code would have to be modified in order to work.

Original Code: 

#include <Keypad.h>
#include <Servo.h>

Servo servo_Motor;
char* password = "042";
int position = 0;
/*to here*/
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

//Change the following pins your yours keypad pinout!
byte rowPins[ROWS] = {7, 2, 3, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 8, 4};    //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
/* */
int redPin = 12;
int greenPin = 13;
/* */


void setup(){
  Serial.begin(9600); //Init serial communication
  /* */
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  servo_Motor.attach(11);
  setLocked(true);
  /* */
}

void loop()
{
char key = keypad.getKey();
if (key != NO_KEY){
Serial.println(key);
}
if (key == '*' || key == '#')
{
position = 0;
setLocked(true);
}
if (key == password[position])
{
position ++;
}
if (position == 3)
{
setLocked(false);
}
delay(100);
}
void setLocked(int locked)
{
if (locked)
{
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
servo_Motor.write(11);
}
else
{
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);
servo_Motor.write(90);
}
}

Edited Code Snippet:

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

//Change the following pins your yours keypad pinout!
byte rowPins[ROWS] = {7, 2, 3, 5}; //connect to the row pinouts of the keypad

byte colPins[COLS] = {6, 8, 4, 9}; //connect to the column pinouts of the keypad

Bibliography & References
[1] http://www.instructables.com/id/LOCKED-BOX-Arduino-Keypad-3x4-Servo/
[2] http://www.instructables.com/id/Connecting-a-4-x-4-Membrane-Keypad-to-an-Arduino/

Comments

Popular posts from this blog

Unity Project 4: Ball platformer game

Reflective Post

[Research] Traditional Poster Design (4CTA1214)