Introduction: PASSWORD LOCK
Welcome to this instructables ! This instructable model is really easy to make the code and materials are easy to find. In this instructable you will learn to make a passcode thinking you are giving the password to someone when really you are tricking them. This is a fun trick to use on your teachers, peers, siblings ,and etc. The materials you will use are easy to find on Ebay for very cheep. This is a very good lesson to teach in class for begginers as well. For further a due lets get started ! :))
Step 1: Step 1: Materials
Gather all of your materials what you would need for this project: These are easy to find on Ebay and very cheap if used for students.
- Bread board (any size)
-Male to female wires
-4X4 Keypad OR 4X3 keypad (in this model I will be showing it with the 4X4 key pad)
-Relay
- 16X2 LCD
Step 2: Step 2: How It Works
How this instructable works is no matter what number or code for the password is put in it will be always wrong and it will lock it self. This is a good prank to play on anyone. This would be a fun prank to play on the class for April fools day for computer science and engineering teachers. >:)
(" ENTER PASSWORD:) ");("Input correctly!");
Step 3: Step 3 : Schematic
Step 4: Step 4: CODE
/*******************************************************
* name:Password Lock * function: the I2C LCD1602 will display "Welcome!" after power on. * At this point, the indicator LED on the relay keeps off. * When you press "*" key, it will prompt "Input Your Code:". If you enter “123456” and press “#” key to confirm, * the indicator LED on the relay module will light up. The I2C LCD1602 will display "Input Correctly" "Please Come In". * Two seconds later, "Welcome!" *********************************************************/ #include #include #include LiquidCrystal_I2C lcd(0x27,16,2); #define relayPin 3 //relay attach to pin 3 const byte ROWS = 4; //four rows const byte COLS = 4; //four columns //define the cymbols on the buttons of the keypads char hexaKeys[ROWS][COLS] = { { '1','2','3','4' }, { '5','6','7','8' }, { '9','A','B','C' }, { 'D','*','0','#' } }; byte rowPins[ROWS] = { 4, 5, 6, 7}; //connect to the row pinouts of the keypad byte colPins[COLS] = { 8, 9, 10, 11}; //connect to the column pinouts of the keypad int pos = 0; char secretCode[6] = { '1', '2', '3', '4', '5', '6'}; char inputCode[6] = { '0', '0', '0', '0', '0', '0'}; //initialize an instance of class NewKeypad Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); void setup() { lcd.init(); //initialize lcd lcd.backlight(); //turn the backlight pinMode(relayPin, OUTPUT); //set the relay as OUTPUT //Serial.begin(9600); lcd.setCursor(0,0); lcd.print(" ENTER PASSWORD:)"); delay(2000); } void loop() { readKey(); } void readKey() { int correct = 0; int i; char customKey = customKeypad.getKey();//get the key value if (customKey) { switch(customKey) { case '*': //if press in "*" ,then print "Input Your Code:" pos = 0; lcd.clear(); lcd.setCursor(0,0); lcd.print("Wrong password"); break; case '#': //if press in "#" ,then see the password whether "1 2 3 4 5 6" for(i = 0; i < 6; i++) { if(inputCode[i] == secretCode[i]) { correct ++; } } if(correct == 6)//if it right { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Input correctly!");//print "Input correctly!" lcd.setCursor(0, 1); lcd.print(" Please Come In "); //print "Please Come In" digitalWrite(relayPin, LOW); //relay connected delay(2000); lcd.clear(); //clear the lcd lcd.setCursor(0,0); lcd.print("ENTER PASSWORD:)"); digitalWrite(relayPin, HIGH); } else { lcd.clear(); lcd.setCursor(0, 0); lcd.print("locked:( "); lcd.setCursor(0, 1); lcd.print(" try Again "); digitalWrite(relayPin, HIGH); delay(2000); lcd.clear(); lcd.setCursor(0,0); lcd.print("ENTER PASSWORD:)"); } break; default: inputCode[pos] = customKey; lcd.setCursor(pos,1); lcd.print(inputCode[pos]); pos ++; } } }