Quick question

Beginner here, I am working with the HelloKeypad example file as a start.

Input from the keypad is working, I see numbers show up on the screen when i hit the serial monitor eye glass thing.

My Question is, how does this library/example work? I want to be able to save the input from the keypad/user and store it and maybe down the line check to see if it matches a password and then light up an led or something, how can I do that?

here is the keypad code so far:

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 3, 2}; //connect to the column pinouts of the keypad

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

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

void loop(){
char key = keypad.getKey();

if (key){
Serial.println(key);
}
}

:slight_smile:

wriley2018:
My Question is, how does this library/example work?

It works really, really well. Joking. But have you run it? It prints the value of 'key' so you can test the variable 'key' with if statements or switch/case statements, to do various things.

Not serial.println, but Serial.println, like in the code you posted.

Edit: hey, what happened to your post?

TheMemberFormerlyKnownAsAWOL:
Not serial.println, but Serial.println, like in the code you posted.

Edit: hey, what happened to your post?

aarg:
It works really, really well. Joking. But have you run it? It prints the value of 'key' so you can test the variable 'key' with if statements or switch/case statements, to do various things.

Thank you for responding! Sorry if its kind of a dumb question i'm not familiar with some of the commands here. like I know printf("") what is serial.prinln ?

and what does keypad keypad =keypad(xyz) mean? I have some idea that its a function taking in values and spitting something out, but where is the function definition? I'm really lost, do you know if there is a tutorial out there that teaches you how to use this library?

so anyways input from the user is being stored in 'key' ? via the .getkey(); command?

TheMemberFormerlyKnownAsAWOL:
Not serial.println, but Serial.println, like in the code you posted.

Edit: hey, what happened to your post?

I deleted it when i realized you can kinda sorta quote/reply directly to people instead of juts replying to the entire post in general....but then i had to wait because i'm new to this forum so i can only post like every 5 mins lol

For checking password, see Arduino password with keypad

IoT_hobbyist:
For checking password, see Arduino password with keypad

thank you, exactly what i was looking for

wriley2018:
like I know printf("") what is serial.prinln ?

Wow, I asked myself the same question when I got into this. But there is a reason, actually, I can't promise that this is it, but I hazily remember that printf() just used up too much memory on a small processor. But with libraries, you can use the '<<' streaming operators for serial output, as is very common in C++. That makes the print functions less verbose in the source code.