hello evrybody i want to know how i can command the time of function key=mykeypad.waitForKey();
because the programm still not working untill i press a button
sorry for The language
i want to know how i can command the time of function
Simple. Don't use waitForKey() if you don't want to wait indefinitely.
because the programm still not working
What program?
void loop() {
flag = true;
lcd.clear();
lcd.print("Password:");
for(int i = 0; i < sizeof(password); i++){
char key = myKeypad.waitForKey();
if(key != password*){*
- flag = false; *
- }*
_ lcd.print("*");_
- }*
the program still not working untill i press a key button but i would to make a method to limit the waitForKey in (10s)
Can you please clarify more
so how the program becomes
Code tags please! Thanks - Moderator.
#include <LiquidCrystal.h>
#include <Keypad.h>
// Keypad
const byte ROWS = 4; //four rows
const byte COLS = 3; //four columns
//define the cymbols on the buttons of the keypads
char keymap[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {0, 1, 2, 3}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 5, 6}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad myKeypad = Keypad( makeKeymap(keymap), rowPins, colPins, ROWS, COLS);
// create and initialize the LCD object
// LiquidCrystal(rs, enable, d4, d5, d6, d7)
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
char password[] = {'0', '0', '0','0', '0', '0'};
boolean flag;
void setup() {
lcd.begin(16, 2);
lcd.cursor();
}
void loop() {
flag = true;
lcd.clear();
lcd.print("Password:");
for(int i = 0; i < sizeof(password); i++){
char key = myKeypad.waitForKey();
if(key != password[i]){
flag = false;
}
lcd.print("*");
}
lcd.setCursor(0 ,1);
if(flag == false){
lcd.print("Incorrect !!");
}else{
lcd.print("Correct");
}
delay(300);
}
this is all of the sketch but the proble is how ican make a delay when Lack of pressure because the function waitForKey interrupt them to make delay