I want it to ask for the level, then once I input one it prints the level.
#include <LiquidCrystal.h> //import lcd library
#include <Keypad.h> //import keypad library
LiquidCrystal lcd(5, 4, 3, 2, 1, 0); //lcd pins
const byte ROWS = 4; // four rows
const byte COLS = 4; // four columns
//define the keymap
char keys [ROWS] [COLS] = {
{'1', '4', '7', 'X'},
{'2', '5', '8', '0'},
{'3', '6', '9', '='},
{'+', '-', '*', '/'}
};
byte rowPins[ROWS] = {
9 ,8 ,7 ,6}; //connect keypad ROW1, ROW2, ROW3, ROW4 to these arduino pins
byte colPins[COLS] = {
13, 12, 11, 10}; //connect keypad COL1, COL2, COL3, COL4 to these arduino pins
//create the keypad
Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int number1;
int number2;
int operation;
int level;
int answer;
void setup(){
// while (operation && level == 0) {
//delete the char
char key = NO_KEY;
level = 0;
lcd.begin(16,2);
lcd.clear();
//delete the lcd.begin
lcd.print("set level");
lcd.setCursor(0,1);
lcd.print("1-3");
while(level == 0);
key = myKeypad.getKey();
if (key != NO_KEY && (key=='1'||key=='2'||key=='3')){
level = (key - 48);
}
lcd.clear();
lcd.print(level);
delay(10000);
}
void loop(){
}
It works but when I try and input a level it does… nothing
can you please help?