password library + lcd + 4x3 keypad

Hi! I've made a vault wherein you need to enter a 5-digit password. The password library really helped me and now I'd like to add a new feature to my project wherein you can change the password by entering a new password through the keypad and not by directly changing the password from the code?

Now here's my problem:

How can I store a 5-digit input from the keypad so that I can use it for the new password?

well I'm thinking about doing this:

char newPass[6];              //this will store the 5-digit password 
int i=0;
while (keypad.getKey()!=NO_KEY)
{
  newPass[i]=keypad.getKey();      //this will get 1 input from the keypad and store it until it reaches newPass[4]
  newPass[5] = '\0';                      //
  i++;
}
lcd.setCursor(0,1);                     //this will be used for testing, so that I can see if it really stores what I enter from the keypad
lcd.print(newPass);                     //this must print the 5-digit password.

I'd use EEPROM

AWOL: I'd use EEPROM

ohh.. don't know how to use that, don't even know what it is. :~

Psst, up there, on the right, there's a search tool. There's also one over at the main site (link, up there, on the left)

Hi! I’ve made a vault wherein you need to enter a 5-digit password. The password library really helped me

How will you trigger the “need to collect a new password” function?

while (keypad.getKey()!=NO_KEY)
{
  newPass[i]=keypad.getKey();      //this will get 1 input from the keypad and store it until it reaches newPass[4]
  newPass[5] = '\0';                      //
  i++;
}

How will this while loop know when to stop? If getkey() blocks until a key is pressed, that key won’t be available on the next call to getKey(). If getKey() is non-blocking, then the key will still be available on the next call, and it will be stored. But, then the loop body ends, and getKey() is called again. The same key is still pressed, so it’s read again and stored again, over and over, far overrunning the end of the array.

Presuming you get this to collect exactly 5 characters, where will you store this password? If it is stored only in SRAM, it will be lost when the Arduino resets.

You need to store the new password in EEPROM, and read it from there in setup().

Ok so I need to study first the EEPROM and will be right back when I'm through.. :D

http://arduino.cc/en/Reference/EEPROM

Quote Hi! I've made a vault wherein you need to enter a 5-digit password. The password library really helped me How will you trigger the "need to collect a new password" function?

That's my problem now.. The password library only helped me in comparing the preset password to the password being entered via keypad.

Code:

while (keypad.getKey()!=NO_KEY) { newPass*=keypad.getKey(); //this will get 1 input from the keypad and store it until it reaches newPass[4]* * newPass[5] = '\0'; //* * i++;* } How will this while loop know when to stop? If getkey() blocks until a key is pressed, that key won't be available on the next call to getKey(). If getKey() is non-blocking, then the key will still be available on the next call, and it will be stored. But, then the loop body ends, and getKey() is called again. The same key is still pressed, so it's read again and stored again, over and over, far overrunning the end of the array. [/quote] I am still not sure if that code will work though. Is there any other way I could store 5 digit input from the keypad? Thanks!!

Ok so I use Diecimila so meaning it can only store 512bytes

You only need to store 5, so, you’ll still have 507 bytes left.

and each byte can only hold values from 0-255.

Is that a problem? How many keys does your keyboard have?

  keypad.getKey();
  if (keypad.getKey()!=NO_KEY)

The very first thing you need to do is figure out exactly what the getKey() function does.

It returns a value that you are throwing away. Why?

I'm trying to store input from the keypad to the EEPROM but no luck. Don't know what is wrong.

Until you tell us, we don't either. There must be more details that you can share. What proof do you have that the data is not being stored in EEPROM?

^ I guess that code isn't really working.. whew!

Hello there! Quick question, is it okay to use 12V, 2A power adaptor for my diecimila board or does it have current limit?? If it is okay, will it be able to provide enough current and voltage if I add servo motor and gsm module?

Anyways, I’m still working on my code regarding the EEPROM and saving data to it.

Quick question, is it okay to use 12V, 2A power adaptor for my diecimila board

Current is pulled. The Arduino will only pull what it needs, which will be nowhere near the 2A that adapter is capable of delivering.

will it be able to provide enough current and voltage if I add servo motor and gsm module?

For the GSM, yes. For the servo, yes, but...

You do not want all the current that the servo needs running through the delicate traces on your Arduino. Tap the adapter directly for powering the servo. The servo ground and Arduino ground do need to be connected.

Tap the adapter directly for powering the servo.

On second thoughts, don't - servos are typically 6V devices. Don't power them off the Arduino, but don't whack 'em with 12V either.

On second thoughts, don't

Oh, yeah. I was thinking in terms of protecting the Arduino, not the servos. Probably don't want to destroy them, either.

so should I only use the adapter to power the arduino and gsm module and not servo? Or should I have two power adapters for the gsm and servo? I'm still kinda confuse. :~

In this case, my current password is '13579'.

You need to create a sketch that stores the current password in EEPROM, as some location.

When you get the "Enter a new password" function working, store the new password in EEPROM, in that same location.

Then, in the main sketch, add the "Enter a new password" function, along with a mechanism to invoke it.

In setup(), read the stored password. That is the valid password for entry.

Do not do this until the "Enter a new password" function has been thoroughly tested and debugged, unless you want to lock yourself out.

Apple recently released a patch for a function they wrote that allowed users to remotely change the unlock password on their servers. Doing so bricked the server. My son was the first victim, but not the only one. Apple ended up having to replace the hard-drive and motherboard on every server that the function was used on. Your screw-up in releasing a non-thoroughly tested password changer function might not cost you as much, but it is still embarrassing.

Should I still use the password library or should I just use only the EEPROM to save and read the current password and the new password?

Should I still use the password library or should I just use only the EEPROM to save and read the current password and the new password?

It’s not an either/or question. The valid password is stored in EEPROM. That gets read and stored in the array that the password library is comparing the collected password to.

You need both.

You need to create a sketch that stores the current password in EEPROM, as some location

When you get the "Enter a new password" function working, store the new password in EEPROM, in that same location.

I use 0,1,2,3,and 4 as the addresses for saving data on the EEPROM. So am I going to write my current password which is '13579' to that addresses and leave this code as it is?

Password password =Password("13579");

I'm thinking about retrieving all the data in the EEPROM when a new password is saved and substitute it to that code so it will give me something like this:

char newPassword[6]; //this contains all the data on the address 0,1,2,3 and 4 of the EEPROM

Password password = Password(newPassword);

I don't know if that is possible and if that will work. Can you give me a sample code so that i know what to do..? I'm kinda new to this stuff and my programming skill is not good. All I do is self study but don't have enough time so forgive me If you think I ask too much from you guys. Thanks!