Trying to make program menu with LCD 16X2 + Keypad 4X4

Hi all,

I have an arduino uno that connected to a 16x2 LCD and 4x4Keypad.

I am trying to make a initiation menu that will get the program parameters and will run only in the "setup()" section.

In the start of the program (setup() section) the user will get a opening screen such as this:

"Press A to start" "the program init"

and after the user will press A, he will get a set of few screens to set the program parameters. example: "1.Time Sync:" " Hr:Min:Sec "

"2. Date Sync" "dd/mm/yyyy"

"3.Tank Capacity" "Capacity:"

My problem is that i need that the user will enter the parameter and will press A (example: the tank capacity is 5L, so when the LCD display: "3.Tank Capacity" "Capacity:" the user should press 5 and then A)

i will very Appreciate the help.

You haven't shown us any of the code you've written, so offering specific help is difficult.

If you've got a lot of text to display, make sure you store the strings in PROGMEM.

#include <Keypad.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
byte rowPins[ROWS] = {6, 7, 8, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {0, 1, 10, 13}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  lcd.print("Press A to start");
  lcd.setCursor(0, 1);
  lcd.print("Program init");
  char key = keypad.getKey();
while(key != NO_KEY && key != 'A'){
  lcd.print("Tank Capacity");
  lcd.setCursor(0, 1); 
  char key1 = keypad.getKey();
  lcd.setCursor(8, 1);
  if(key1 !=NO_KEY && key1 != 'A' && key1 != 'B' && key1 != 'C' && key1 != 'D') {
  lcd.print("Fill time");
  lcd.setCursor(0, 1); 

void loop() {


So what's the specific problem?

(can you also please delete your other partial post on this subject?)

it's doesn't work.

the LCD displays the 1th screen: "Press A to start" "the program init"

but nothing happen when i press A...

Have you verified that your keypad is wired correctly and works with the library you are using? (Serial.print is a good way of doing this)

Both of them are working excellent..

Serial prints are still an excellent way of debugging.

well ... sorry but u didn't help me at all.. thanks for the try..

All of your code is in setup. You call keypad.getKey() to get a key. Unless you are holding down a key when the Arduino starts, keypad.getKey() is going to return NO_KEY.

You have a while loop that does something while key is NOT NO_KEY. But, key IS NO_KEY, so the body of the while loop is skipped, ending setup().

You have no code in loop(), so nothing happens.

That being the behavior you are seeing, I would say that there is nothing wrong with the code you have written.

The problem is that you haven't written the code to do what it is you want it to do, and haven't clearly (at least so I can understand it) defined what it is you want to do.

I think you need to either work on the requirements, or learn how to do it on your own.

Don't know if getKey traps execution while waiting for a key press or just reads the keypad once.

nerotix, where does the keypad.h come from? Is it included in arduino IDE or else? A link will be helpful.

thanks for the replay PaulS, of course this only a small part of a big program. in this part my requirements is to display on the LCD 10screens (screen = 2row in the LCD), in each screen the program will ask from the user to enter (by the 4x4 KEYPAD) a parameter that will be display on the LCD, after the user enter the parameter and press 'A' on the keypad the program moves the the next screen and so on.. until the program reach the last screen and then, the program moves to the loop part and uses the parameter that the user entered.

liudr this Keypad.h lib is from the arduino site. enjoy:

You could have a look at this library:

It helps with managing menu logic navigation and hierarchical structure.

thanks a lot this is very interesting thanks