-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Description
Hi guys, i'm working on a security box that use a keypad 4x3 matrix for the user inputs.
I want allow the user to change his password in this way :
- Insert new password
- press * for 3 seconds for confirm
Ok, the problem is the second one, because i'm trying to use the library's functions , like .getState() or .isPressed() , but all of them have a bug (i think), because if i press any button, the state of the pad changes into PRESSED (and it's ok), then if i release, the state still be PRESSED instead of RELEASED.
It's seems like the "refresh" doesn't read the pull-up, and the state remains in ground.
/* Utilizzo un keypad 4x3 e mando in output su seriale il tasto premuto */
/* NOTA : Per le variabili intere uso "byte" al posto di "int" perchè mi consente di risparmiare spazio, 1 byte al posto di 2 per "int". */
#include <Keypad.h>
const byte COLS = 3;
const byte ROWS = 4;
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[4] = {8,7,6,5}; //connect to the row pinouts of the keypad
byte colPins[3] = {4,3,2}; //connect to the col pinouts of the keypad
// Creo un oggetto di tipo Keypad , dove specifico : mappa_tasti, pin_righe, pin_colonne, Num_righe, Num_colonne
Keypad pad = Keypad( makeKeymap(keys), rowPins,colPins,ROWS,COLS);
void setup(){
Serial.begin(9600);
delay(1000);
Serial.println(F("ready"));
pad.waitForKey();
}
void loop(){
if(pad.isPressed('1')){
Serial.println("1");
}else if(pad.isPressed('2')){
Serial.println("2");
}else if(pad.isPressed('3')){
Serial.println("3");
}
}
If there's someone that can be useful, please be.
Thank you all!
Metadata
Metadata
Assignees
Labels
No labels