i'm not sure if correct terminology, making keypad lock cycles through 10 pin numbers, once password1 has been used password2 active code, when used password3 active code , on.
the basic idea add integer (i) end of password, when correct pw entered ++i code looking password(i) 6 next time = 7 code password7.
i cant find way add integer value end of 'password' void check password method.
code snippet
this problem
if (password(i).evaluate()){ // check pass code 0 10
i have tried password + (i) , few other formats no luck yet
full code
any appreciated!
many
the basic idea add integer (i) end of password, when correct pw entered ++i code looking password(i) 6 next time = 7 code password7.
i cant find way add integer value end of 'password' void check password method.
code snippet
code: [select]
password password = password ("123456");
password password1 = password ("695847");
password password2 = password ("176234");
password password3 = password ("951086");
password password4 = password ("986510");
password password5 = password ("284396");
password password6 = password ("084763");
password password7 = password ("412763");
password password8 = password ("407195");
password password9 = password ("274069");
password password10 = password ("074859");
void checkpassword() {
if (password(i).evaluate()){ // check pass code 0 10
serial.println(" ok.");
++; // add 1 every time correct pw used
if (i == 10) = 0; // reset 0 when 10 codes used
} else {
serial.println(" wrong passwowrd!");
}
this problem
if (password(i).evaluate()){ // check pass code 0 10
i have tried password + (i) , few other formats no luck yet
full code
code: [select]
#include <keypad.h>
#include <password.h>
string newpasswordstring; //hold new password
char newpassword[6]; //charater string of newpasswordstring
//initialize password 1234
//you can use password.set(newpassword) overwrite it
password password = password ("123456");
password password1 = password ("695847");
password password2 = password ("176234");
password password3 = password ("951086");
password password4 = password ("986510");
password password5 = password ("284396");
password password6 = password ("084763");
password password7 = password ("412763");
password password8 = password ("407195");
password password9 = password ("274069");
password password10 = password ("074859");
byte maxpasswordlength = 6;
byte currentpasswordlength = 0;
const byte rows = 4; // 4 rows
const byte cols = 4; // 4 columns
int = 0;
//define keymap
char keys[rows][cols] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
//// connect keypad row0, row1, row2 , row3 these arduino pins.
byte rowpins[rows] = {6,7,8}; //connect row pinouts
// connect keypad col0, col1, col2 , col3 these arduino pins.
byte colpins[cols] = {2,3,4,5}; //connect column pinouts
// create keypad
keypad keypad = keypad( makekeymap(keys), rowpins, colpins, rows, cols );
void setup(){
serial.begin(9600);
}
void loop(){
char key = keypad.getkey();
if (key != no_key){
delay(60);
switch (key){
case 'a': break;
case 'b': break;
case 'c': break;
case 'd': changepassword(); break;
case '#': checkpassword(); break;
case '*': resetpassword(); break;
default: processnumberkey(key);
}
}
}
void processnumberkey(char key) {
serial.print(key);
currentpasswordlength++;
password.append(key);
if (currentpasswordlength == maxpasswordlength) {
checkpassword();
}
}
void checkpassword() {
if (password(i).evaluate()){ // check pass code 0 10
serial.println(" ok.");
++; // add 1 every time correct pw used
if (i == 10) = 0; // reset 0 when 10 codes used
} else {
serial.println(" wrong passwowrd!");
}
resetpassword();
}
void resetpassword() {
password.reset();
currentpasswordlength = 0;
}
void changepassword() {
newpasswordstring = "123";
newpasswordstring.tochararray(newpassword, newpasswordstring.length()+1); //convert string char array
password.set(newpassword);
resetpassword();
serial.print("password changed ");
serial.println(newpasswordstring);
}
//void resetpassword() {
//do resetpassword
//}
any appreciated!
many
quote
i cant find way add integer value end of 'password' void check password method.it wouldn't good, anyway. names not exist @ run time. addresses do, , stored in array if created array of password objects.
Arduino Forum > Using Arduino > Programming Questions > adding an incremental value to the end of a variable
arduino
Comments
Post a Comment