Change password option

Hi guys,

I encounterd a small problem in my current project.
I'm trying to build a program that will display a message when the code is enterd correctly (wish it does).
But also i'd love to have a "change password" function in this, but this is the tricky part.
I can't seem to get the code below to work... my whay of thinking whas to store the keystrokes in a Array and then set it as a password but this doens't seem to work.

Does anyone have an idea to fix this ?

Much thanks!
Best regards!

Code:

void changePassword() {
  resetPassword();
  moveCursor("01", "01"); 
  Serial.print("Type new pass:");
  moveCursor("02", "01"); 
  while (maxPasswordLength > data_count)
  {
    char key = keypad.getKey();
    if (key)
    {
      Data[data_count] = key; 
      Serial.print(Data[data_count]);
      data_count++;
    }
  }
   password.set(Data[data_count]);
   resetPassword();
   Serial.print("Password changed to ");
   Serial.print(Data[data_count]);
   resetPassword();
}

Compiling Error:

invalid conversion from 'char' to 'char*'
sketch_jul21a.cpp: In function 'void changePassword()':
project1:94: error: invalid conversion from 'char' to 'char*'
project1:94: error: initializing argument 1 of 'void Password::set(char*)'

Not a snowball's chance in hell that you'll get help with those snippets. Post ALL of your code.

What the hell is resetPassword() doing that needs to be done THREE times in that function?

P.S. The Password::set() method takes an array of chars, not a single char.

As requested , here is the full code.

#include <Password.h>
#include <Keypad.h>
#include <iobridgelcd.h>


char newPassword[6]; //charater string of newPasswordString
byte maxPasswordLength = 6;
byte currentPasswordLength = 0;



char Data[7]; // 6 is the number of chars it can hold + the null char = 7
byte data_count = 0;

Password password = Password( "123456" );

const byte ROWS = 4;
const byte COLS = 4;
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};
byte colPins[COLS] = {9, 8, 7, 6};

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

void setup(){
  Serial.begin(9600);
  clearLCD();
}

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);
      }
   } 
}//Loop

void processNumberKey(char key) {
   Serial.print(key);
   currentPasswordLength++;
   password.append(key);
   if (currentPasswordLength == maxPasswordLength) {
      checkPassword();
   }
}

void checkPassword() {
   if (password.evaluate()){
      moveCursor("02", "01");
      Serial.print(" OK.");
   } else {
      moveCursor("02", "01");
      Serial.print(" Wrong passwowrd!");
      
   }
   resetPassword();
}

void resetPassword() {
   password.reset();
   currentPasswordLength = 0;
   moveCursor("01", "01"); 
   delay(1000);
   clearLCD();
}

void changePassword() {
  resetPassword();
  moveCursor("01", "01");
  Serial.print("Type new pass:");
  moveCursor("02", "01");
  while (maxPasswordLength > data_count)
  {
    char key = keypad.getKey();
    if (key)
    {
      Data[data_count] = key;
      Serial.print(Data[data_count]);
      data_count++;
    }
  }
   password.set(Data[data_count]);
   resetPassword();
   Serial.print("Password changed to ");
   Serial.print(Data[data_count]);
   resetPassword();
}
   if (key != NO_KEY){
      delay(60);
      switch (key){

If a key was pressed, take a break. Why? Did you really work up a sweat pressing the key?

  while (maxPasswordLength > data_count)

While 6 is greater than 0... Do you really think that way? Write code the way you think:

  while(data_count < maxPasswordLength)
      moveCursor("02", "01");

Where is this function defined? Why on earth does it take string to define positions?

   moveCursor("01", "01"); 
   delay(1000);
   clearLCD();

More time wasting...

  while (maxPasswordLength > data_count)
  {
    char key = keypad.getKey();
    if (key)
    {
      Data[data_count] = key;
      Serial.print(Data[data_count]);
      data_count++;
    }
  }

God forbid you should make a mistake.

   password.set(Data[data_count]);

After the while loop ends, what is the value of data_count? Isn't it 6? So, you want the new password to be the NULL at the end of the array?

The password.set() method needs the whole array:

   password.set(Data);
   resetPassword();
   resetPassword();

Perhaps you should try:

   resetPassword();
   resetPassword();
   resetPassword();
   resetPassword();
   resetPassword();
   resetPassword();
   Serial.print("Password changed to ");
   Serial.print(Data[data_count]);

The password was changed to the NULL, huh?

Thanks for your feedback , maybe abit less sarcasm whould be nice .
i have solved the problem and fixed the errors you had showd me .

Thanks though ...

Can you please put here your solved code coz I wanna refer it on our thesis if how did you solved it? Thanks by the way.