Hi,
I am using a 4x3 keypad and trying to create password program. Here I am using a switch case structure that asks to press * for getting the menu. After entering the menu, it is required to choose option from the list using keypad. But instead of choosing option it always prints "invalid key" which is default option. Can you please help me to properly write the code? I have attached the code and the supporting files for further reference to the code.
Thanking You
[//*Key pad interfacing using 4x3 keypad*/
#include"myKey.h"
#include"Functions.h"
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.begin(9600);
Serial.println("Welcome...");
Serial.println("Press * to enter menu");
}
void loop() {
// put your main code here, to run repeatedly:
char key=kpd.getKey();
if(key!=NO_KEY)
{
switch(key)
{
case '*':
{
showNextMenu();
chooseOption();
}
break;
default:
Serial.println("Invalid Key");
exit;
}
}
}
void showNextMenu(void)
{
Serial.println("1:open box");
Serial.println("2:change passwd");
Serial.println("Any:exit menu");
/*
char key=kpd.getKey();
if(key!=NO_KEY)
{
delay(2000);
switch(key)
{
case '1':
openBox();
break;
case '2':
changePwd();
break;
default :
exit;
}
}*/
}
void chooseOption(void)
{
Serial.println("Enter choice..");
delay(1000);
char key=kpd.getKey();
if(key!=NO_KEY)
{
delay(100);
switch(key)
{
case '1':
openBox();
break;
case '2':
changePwd();
break;
default :
Serial.println(" see you next time");;
}
}
}
]
pwd.h (64 Bytes)
myKey.h (770 Bytes)
Functions.h (239 Bytes)
Functions.cpp (1.36 KB)
Arduino_Keypad_with_LCD.ino (1.35 KB)