Getting one digit from the keypad is easy, but how do you get two or three digits from the user (through the keypad) and use it to do something useful.
You read the keypad as many times as you need. Either a fixed number of times, or until a terminating character is entered. As keys are read, you store them, or add them together, in whatever way is appropriate. When you have a complete entry, act on it.
You just need to keep track of the number you are creating from the input. Every time you get a new input, multiply this by ten and add the new input to it. It's hard to create a solid example without more specifics, but something like the following should work:
int number = 0;
while( <more_input_required> )
{
number *= 10;
number += get_input();
}
Of course, you'll need to replace <more_input_required> with your own condition (no. of digits expected etc.) and replace get_input() with whatever function you call to get the next input.
Can someone give me some feedback on what I am doing wrong.
Sure. It's pretty simple, really. You have a Serial.begin() statement, but no Serial.print() statements, to tell what is happening.
keypad.getKey();
The getKey() method returns a value. If you are not going to use the value, it makes no sense to call the method.
Some things to care about. Is the keypadEvent() function ever called? In that function, the event is not the same as the key. An event is like keyPressed (a key was pressed) or keyReleased (the key is no longer pressed). The password class is concerned about characters, not events.
I thought these all looked fairly similar, so I merged them.
AWOL:
I thought these all looked fairly similar, so I merged them.
I thought I was reading up this post and then ...
I think the event is not actually interrupt driven as I learned from a recent post. The event is called every time getKey is called so it's a callback function (right?).
Not sure about the password library at all. Why do people use it instead of strcpy is beyond me. I do strcpy strcmp. It's simple.
Not sure about the password library at all. Why do people use it instead of strcpy is beyond me. I do strcpy. It's simple.
strcpy()? Or strcmp()?
The password class hides the complexity (?) of defining and initializing the array, adding the new character to the end of the array, and comparing the contents of the array against a predefined string.