Hallo,
Ik ben bezig met een maken van een kluis systeem waarbij je 1 arduino gebruikt en meerdere relais voor de solenoid. Het is de bedoeling dat ik voor elke kluis een andere pincode intoets. dus kluis van "andy" gaat open als ik 1234 en dan # in toets en van "Mike" gaat open als ik 8520 intoets enzovoort.
Ik heb een password library gevonden deze heet "NewPasswordv2".
Het lukt mij om kluis van een gebruiker te openen, maar als ik tweede of derde gebruiker toevoeg dan werkt het niet meer.
dus mijn vraag aan jullie is zouden jullie mij willen helpen?
Hier is de code
#include <NewPasswordV2.h>
#include <Keypad.h>
NewPasswordV2 Mypass1;
NewPasswordV2 Mypass2;
NewPasswordV2 Mypass3;
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
char Name[10];
char *Pword1 = " ";
char *Pword2 = " ";
char *Pword3 = " ";
char data1;
void setup()
{
Serial.begin(115200);
Mypass1.EnterKey('#'); // MANUAL MODE Must add # at the end of password to enter it
Mypass1.BackSpaceKey('*'); // MANUAL MODE '-' or (Backspace Key) will delete an index of the password array before checking it.
Mypass2.EnterKey('#'); // MANUAL MODE Must add # at the end of password to enter it
Mypass2.BackSpaceKey('*'); // MANUAL MODE '-' or (Backspace Key) will delete an index of the password array before checking it.
Mypass3.EnterKey('#'); // MANUAL MODE Must add # at the end of password to enter it
Mypass3.BackSpaceKey('*'); // MANUAL MODE '-' or (Backspace Key) will delete an index of the password array before checking it.
Mypass1.AddPassword("1111", "Andy"); // password, name, function.
Mypass2.AddPassword("2222", "Mike"); // regular password and username, no function required.
Mypass3.AddPassword("0000", "Joe");
}
void loop()
{
char key = keypad.getKey();
if (key) {
Serial.println(key);
}
data1 = key;
if (Mypass1.EnterData(data1, Pword1))
{
if ( Mypass1.CheckPassword(Pword1) )
{
Serial.print(F("Acces 1 Granted: "));
// Here comes the code to open Andy's locker.
Serial.print(Mypass1.CheckUser());
Serial.println();
}
}
if (Mypass2.EnterData(data1, Pword2))
{
if ( Mypass2.CheckPassword(Pword2) )
{
Serial.print(F("Acces 2 Granted: "));
// Here comes the code to open Mike's locker.
Serial.print(Mypass2.CheckUser());
Serial.println();
}
}
if (Mypass3.EnterData(data1, Pword3))
{
if ( Mypass3.CheckPassword(Pword3) )
{
Serial.print(F("Acces 3 Granted: "));
// Here comes the code to open Joe's not joe mama locker.
Serial.print(Mypass3.CheckUser());
Serial.println();
}
}
}
en dit is het stuk waar ik meerdere gebruikers toevoeg. de eerste werkt maar als de code voor de tweede en derde komt dan werkt het niet.
if (Mypass1.EnterData(data1, Pword1))
{
if ( Mypass1.CheckPassword(Pword1) )
{
Serial.print(F("Acces 1 Granted: "));
// Here comes the code to open Andy's locker.
Serial.print(Mypass1.CheckUser());
Serial.println();
}
}
if (Mypass2.EnterData(data1, Pword2))
{
if ( Mypass2.CheckPassword(Pword2) )
{
Serial.print(F("Acces 2 Granted: "));
// Here comes the code to open Mike's locker.
Serial.print(Mypass2.CheckUser());
Serial.println();
}
}
if (Mypass3.EnterData(data1, Pword3))
{
if ( Mypass3.CheckPassword(Pword3) )
{
Serial.print(F("Acces 3 Granted: "));
// Here comes the code to open Joe's not joe mama locker.
Serial.print(Mypass3.CheckUser());
Serial.println();
}
}
ik heb niet zoveel codeer ervaring dus ik zou het erg op prijs stellen als je specefiek zegt wat niet goed is.
Ik heb het zip bestand voor de library ook erin gezet als een bijlage.
NewPasswordV2.zip (7.39 KB)