19 October 2019

Password Hint!


For this project, users need to follow some steps to find the required password. They need to access the serial monitor and type '1', an equation will appear on the serial monitor, and a message will display on the LCD. Users need to type '2' and '3' to get the rest of the other equations. The answers to the equations are the digits of the password. They need to press the digits at the same order of the equations; they also need to press the sequence on the keypad twice.  



Figure 1, Video


Figure 2, Picture


Figure 3, Sketch


Figure 4, Instructions


Figure 5, Schematic


#include <Keypad.h>
#include <LiquidCrystal.h>
//lcd pins
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);
//keypad info
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','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
char* password ="2580"; //create password
int pos = 0; //keypad position
void setup(){
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop(){
char customKey = customKeypad.getKey(); //def. which key is pressed
//begin
lcd.setCursor(0, 0);
lcd.print("Hi!");
lcd.setCursor(0, 1);
lcd.print("Enter Password:");
//Invalid keys
if(customKey == '*' || customKey == '#' ||
customKey == 'A' || customKey == 'B' ||
customKey == 'C' || customKey == 'D') {
pos = 0;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Invalid Key!");
delay(1000);
lcd.clear();
}
//password varification
if(customKey == password[pos]) {
pos ++;
}
if(pos == 4){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" **Varified!**");
lcd.setCursor(0, 1);
lcd.print(" **Good Job!**");
delay(5000);
lcd.clear();
pos = 0;
}
//serial monitor data
if(Serial.available() > 0) {
char p = Serial.read();
Serial.println(p);
if(p == '1'){
Serial.println("1+1=?");
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("EASY!");
delay(5000);
lcd.clear();
}
if(p == '2'){
Serial.println("your first answer+1+1+1=?");
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Almost there!");
delay(5000);
lcd.clear();
}
if(p == '3'){
Serial.println("480/6=?");
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("You have it now!");
delay(5000);
lcd.clear();
}
}
}
view raw gistfile1.txt hosted with ❤ by GitHub

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.