Keypad Safe

SRJT10203

Jugaadu's father is going on a Business trip. He is carrying some important and confidential documents with him. He wants to keep these documents safe. But his luggage doesn't have a smart locking system. He wants Jugaadu to make a smart locking box that can help him in keeping his documents safe?

  1. Arduino UNOUNO
  2. Tape
  3. Keypad Sensor
  4. Jumper Wires
  5. Cardboard Box
  6. 12V Battery
  7. USB Cable
  8. Foam Sheets
  9. Servo Motor
  10. Glue gun
  11. Cutter

    include 
#include 
Servo myservo;
String password="1306";
String tempPassword="";
const byte ROWS = 4; 
const byte COLS = 4; 
char keyPressed;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9,8,7,6}; 
byte colPins[COLS] = {5,4,3,2}; 
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
Serial.begin(9600);
myservo.attach(10);
} 
void loop(){
keyPressed = keypad.getKey();
if(keyPressed != NO_KEY){
if(keyPressed =='#') 
{
tempPassword="";
myservo.write(0);
}
else if(keyPressed=='*' ) 
{
if(tempPassword==password && tempPassword != ""){
myservo.write(180);
}else{
myservo.write(0);
}
}
else if(keyPressed =='0' || keyPressed=='1' || keyPressed=='2'|| 
keyPressed=='3'|| keyPressed=='4'|| keyPressed=='5'|| 
keyPressed=='6'|| keyPressed=='7'|| keyPressed=='8'|| keyPressed=='9')
{
tempPassword +=keyPressed;
}
Serial.println(keyPressed);
}
}