I am currently making a project which involves the need for a password for each user. Once the user inputs their password, the LCD would display their name. Can you help me on how this could be implemented?
I can help with that. See attachment below.
Added:
I just made this sketch, it shows how you can use a LCD with the library. Note, I have a I2C lcd, so you may need to change a few things if you have a regular lcd.
#include <NewPasswordV2.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20,20,4);
NewPasswordV2 Mypass;
char Name[10]= {NULL};
char Pword[5] = {'\0'};
char data;
void setup(){
lcd.init(); // initialize the lcd
lcd.backlight();
Serial.begin(9600);
Mypass.Init(5); // how long will the password be + null terminator.
Mypass.AddPassword("1234","Andy");
Mypass.AddPassword("abcd","Joe");
Mypass.AddPassword("ASDF","John");
Mypass.AddPassword("8520","Sam");
Mypass.AddPassword("1111","Mike");
}
void loop() {
lcd.setCursor(0,0);
if(Serial.available() > 0 ){
data = Serial.read();
strncpy(Pword, Mypass.EnterData(data), sizeof(Pword));
switch( Mypass.Check(Pword) )
{
case 1:
lcd.clear();
lcd.print("Password was found: ");
lcd.setCursor(0,1);
lcd.print(Mypass.CheckUser());
//lcd.println();
break;
case 0:
lcd.clear();
lcd.print("Password not found ");
EnterNewPassword(); // Comment this out if you do not want to add new passwords
break;
}
}
}
void EnterNewPassword()
{
lcd.setCursor(0,1);
lcd.print("Store it? Y | N: ");
while(1)
{
if(Serial.available() > 0 )
{
char choice = Serial.read();
if(choice == 'y' || choice == 'Y')
{
lcd.print(choice);
lcd.setCursor(0,2);
lcd.print("Enter name.");
int cnt = 0;
while(1)
{
if(Serial.available() > 0 )
{
char name = Serial.read();
if(name == '.' || cnt > 9) break;
else
{
Name[cnt++] = name;
Name[cnt] = '\0';
}
}
}
Newpassword(Pword,Name);
break;
}
else{
lcd.print(choice);
break;
}
break;
}
}
}
void Newpassword(char * New_Pass, char * New_U)
{
Mypass.AddPassword(New_Pass, New_U);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Password was added: ");
}
NPV2.zip (2.69 KB)