diff --git a/challenge 5 b/challenge 5 index 225a77f..810cab2 100644 --- a/challenge 5 +++ b/challenge 5 @@ -1,36 +1,67 @@ #include #include -//keboard -const byte rows = 4; -const byte columns = 4; -char Keys[rows][columns] = { - {'1','2','3','A'}, - {'4','5','6','B'}, - {'7','8','9','C'}, - {'*','0','#','D'}, -}; -byte rowPins[rows]={9,10,11,12}; -byte colPins[columns]={A0,A1,A2,A3}; -Keypad keypad = Keypad(makeKeymap(Keys),rowPins,colPins,rows,columns); -// with the arduino pin number it is connected to -LiquidCrystal lcd(2,3,4,5,6,7); -char str[4]={'1','2','3','4'}; -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16, 0); - // Print a message to the LCD. - lcd.print("password"); - delay(1000); + +LiquidCrystal lcd(7,6,5,4,3,2); +char password[] = "CAB#1729"; +String passwordarr[2]= {"Gmail:YOLO343","Facebook:BYE145"}; +char enterkey ; +int position = 0 ; +int counter = 0 ; +const byte ROWS = 4; +const byte COLS = 4; +char keyMap[ROWS][COLS]= {{'1' , '2' , '3' , 'A'}, + {'4' , '5' , '6' , 'B'}, + {'7' , '8' , '9' , 'C'}, + {'*' , '0' , '#' , 'D'}}; +byte rowpins[ROWS] ={8,9,10,11}; +byte colpins[COLS] ={A0,A1,A2,A3}; +Keypad mykeypad = Keypad(makeKeymap(keyMap),rowpins,colpins,ROWS,COLS); + +void setup() +{ + lcd.begin(16,2); + lcd.setCursor(0,0); + lcd.print("Wlcm 2 Pwd Mngr"); + delay(500); lcd.clear(); } -int counter = 0 ; + void loop() { - char Key = keypad.getKey(); - if (Key == str[counter]) - counter++; - if(counter==4){ + enterkey = mykeypad.getKey(); + lcd.setCursor(0,0); + lcd.print("Enter password"); + lcd.setCursor(0,1); + lcd.print(enterkey); + if ((enterkey=='C')||(enterkey=='A')||(enterkey=='B')||(enterkey=='1')||(enterkey=='7')||(enterkey=='2')||(enterkey=='9')||(enterkey=='#')) + counter++; + if (enterkey == password[position]) + { + position++; + } + if (((enterkey=='*')||(enterkey=='3')||(enterkey=='4')||(enterkey=='5')||(enterkey=='6')||(enterkey=='8')||(enterkey=='D')||(enterkey=='0'))||(counter!=position)) + { + position= 0; + counter=0; + lcd.clear(); + lcd.setCursor(0,0); + lcd.print("Invalid Pwd"); + delay(500); + lcd.clear(); + } + if (position==8) + { + lcd.clear(); lcd.setCursor(0,0); - lcd.print("Facebook : 123abc"); + lcd.print("Correct password"); + delay(500); + lcd.clear(); + for (int k =1;k>=0;k--) + { + lcd.setCursor(0,k); + lcd.print(passwordarr[k]); + if (k==0) + while(1){}; + } } }