Go Down

Topic: Password Libary with Keypad (Read 1 time) previous topic - next topic


Hi all,

im currently doing a password lock project, im having some issues with the code while entering the password, it gives me "invalid password" regardless of the password being right or wrong, anyway here is the code below, any help will be greatly appreciated :)

Code: [Select]

#include <Keypad.h>
#include <Password.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns

char keys[ROWS][COLS] = {
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 9, 8, 7, 6 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 12, 11, 10 };

// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

Password password = Password("1234");

#define ledPin  13

void setup(){
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  digitalWrite(ledPin, HIGH);   // sets the LED on
  keypad.addEventListener(keypadEvent); //add an event listener
void loop(){

//take care of some special events
void keypadEvent(KeypadEvent eKey){
  switch (eKey){
    case '*': tryPassword(); break;
    case '#': password.reset(); break;
   default:  password.append(eKey);

void tryPassword(){
     Serial.print("Guessing password... ");
     if (password.evaluate()){      
Serial.println("VALID PASSWORD "); //
              password.reset(); //resets password after correct entry
Serial.println("INVALID PASSWORD ");
         password.reset(); //resets password after INCORRECT entry


I'm just reading a few lines but maybe it's something in the hardware.

Did you try Serial.print(ekey); for debugging?


thanks for the reply,

i have tried doing that aswell, cant seem to figure it out.. do you know if there is a way to have password without using the password libary? if that makes sense?
sorry my programming is not too good.

Thanks :)

Go Up