Dear all
I am trying to write a code to return number from the keypad, and then make two options as sequence below
1- When the program starts, Enter number and press #
2- Return number,
3-for option one, press A,
4-for option two press B,
I wrote the code for steps 1 and 2 but stuck with 3 and 4.
my code;
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd1(0x26, 20, 4);
long num=0;
//Define OutPuts ports
const int V1=22;
const int V2=23;
// Set 4x4 Keypad
const byte ROWS = 4;
const byte COLS = 4;
char txt1[] = "Press Start";
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {46, 47, 48, 49};
byte colPins[COLS] = {50, 51, 52, 53};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
char entryStr[12]; // This can hold up to 4 digits
void setup() {
pinMode(V1, OUTPUT);
pinMode(V2, OUTPUT);
}
void loop() {
while(1) {
lcd1.clear();
lcd1.setCursor(0, 0);
lcd1.print("Input");
delay(500);
lcd1.clear();
lcd1.print("Filtration Volume");
delay(500);
lcd1.clear();
byte n1 ;
//_________ setting Keypad logic -----------
lcd1.setCursor(0, 0);
lcd1.print("number of l ?");
lcd1.setCursor(0, 1);
lcd1.print("and press #");
unsigned char state;
long num = 0;
char hexaKeys = customKeypad.getKey();
while (hexaKeys != '#')
{
switch (hexaKeys)
{
case NO_KEY:
break;
case 'D': case '2': case '3': case 'A':
case '4': case '5': case '6': case 'B':
case '7': case '8': case '9': case 'C':
case '0': case '1':
lcd1.print(hexaKeys);
num = num * 10 + (hexaKeys - '0');
break;
case '*':
num = 0;
lcd1.clear();
lcd1.setCursor(0, 0);
lcd1.print("number of l ?");
lcd1.setCursor(0, 1);
lcd1.print("and press #");
break;
case '#':
return num;
break;
}
hexaKeys = customKeypad.getKey();
}
} }
Now I need your support to add another option like
if hexaKeys = 1 gotot option A
if hxakeys = 2 goto option B
