Skip to content
If this is your first visit, please click here to learn about shipping and delivery.
If this is your first visit, please touch here to learn about shipping and delivery.
16x2 Character LCD Shield for Arduino - White on Blue

Using a 16×2 LCD Keypad Shield: Button Calibration and Flicker-Free Menus

A 16×2 LCD keypad shield combines a small display and local controls in a convenient format. It is useful for adjusting a setpoint, viewing a sensor or navigating a simple instrument menu. The most common frustrations—blank characters, unreliable buttons and flickering updates—usually become manageable once the pin map and input method are clear.

The PMD Way character LCD shield collection includes a white-on-blue 16×2 keypad shield. Its listing specifies a 5 V shield, an HD44780-compatible interface and five buttons read through A0. It is not intended for direct use on a Due or another 3.3 V board.

Confirm the LCD interface before choosing a library

This shield uses a parallel character-display interface, not an I2C backpack. The Arduino LiquidCrystal library supports HD44780-compatible displays and provides methods for initialisation, cursor positioning and text output.

The linked product specifies this constructor:

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

The arguments identify RS, enable and the four data connections used by the library. Use those assignments only for a board that matches the documented wiring. An I2C display example will not become compatible simply by changing the screen dimensions.

Reserve those pins in the project’s connection table. The shield physically passes some connections onward, but a pin already used by the LCD is not freely available to another peripheral.

Bring up the display before reading buttons

Start with a minimal sketch that initialises 16 columns and two rows and prints a fixed message. Include the LiquidCrystal header and use the constructor matching the shield. Arduino’s character LCD guide explains the reference interface and basic examples.

Adjust the contrast trimmer gently while observing the screen. A lit backlight does not prove that the controller has been initialised correctly. Likewise, a row of dark blocks can indicate power and contrast while the data interface remains wrong.

If text does not appear, check power, ground, shield seating, constructor order and initialisation before investigating the menu logic. Keep the fixed-message sketch as a known-good test.

Understand the analogue keypad

The five buttons share one analogue input through a resistor network. Pressing a button produces a characteristic voltage, which the ADC converts into a number. The program identifies the button by the range containing that number.

Those readings depend on the actual resistor values, supply and ADC configuration. Do not assume a threshold table copied from another shield will work perfectly. The unpressed state also needs its own range.

Most simple resistor-ladder keypads are intended to recognise one button at a time. Simultaneous presses can produce an ambiguous result. If your interface needs key combinations, establish whether the hardware can distinguish them before designing the menu around them.

Calibrate button ranges on the actual board

  1. Print the raw A0 reading with no button pressed.
  2. Press each button separately and record several readings.
  3. Repeat after releasing and pressing again.
  4. Choose non-overlapping ranges with margin between the observed groups.
  5. Treat readings outside those ranges as unknown or no valid event.

For an illustrative keypad, two adjacent button groups might cluster around 140 and 330. A boundary somewhere between them can separate those groups, but the numbers are examples, not settings for the PMD Way shield. Measure your own values.

If two groups overlap noticeably, investigate the wiring, power and input configuration rather than forcing narrower thresholds. Save the calibration values with the specific board or project.

Debounce the identified button

Contact bounce can cause the analogue reading to move briefly between ranges. Debounce the interpreted button state: accept a change only after it remains stable for the chosen interval. Arduino’s debounce example demonstrates the timing principle, which can be adapted from a digital switch to a decoded keypad state.

Generate distinct press and release events. For navigation, you may also want repeat after an initial hold period. Keep repeat timing separate from debounce timing so that improving one does not unexpectedly change the other.

A select or confirm action should generally happen once per deliberate press. Repeating confirmation while a key is held can make a menu skip through several screens unexpectedly.

Update fields without clearing the whole display

Clearing and redrawing the entire LCD on every loop can create visible flicker and unnecessary work. Instead, position the cursor and update fields when their displayed content changes or at a suitable refresh interval.

Use fixed-width fields or pad shorter values with spaces. Otherwise, changing a value from “100” to “9” can leave old characters behind. Decide field widths before writing the screen layout.

Keep units visible and use labels that fit the available columns. On a two-line display, “Set: 25.0 C” and “Now: 24.6 C” are easier to interpret than two unlabeled numbers. Treat this as a layout example, adjusting units and precision to the application.

Separate the menu state from measurement

Maintain a clear distinction between the current measurement, the editable setting and the value actually applied. For example, a user can adjust a proposed setpoint and then confirm it; cancellation should restore the previous value without ambiguity.

Continue servicing sensors and buttons while the menu is open. Avoid long delays used only to keep a message on screen. Use elapsed-time checks so temporary messages can expire while the rest of the application continues running.

Define minimum and maximum settings and clamp changes at the interface boundary. The display should show the value the application will actually use.

Test the awkward transitions

Try changing from a long value to a short one, holding navigation keys, pressing select during an update and restarting while a button is held. Check that unknown keypad readings do not become unintended commands.

Save the pin map, button calibration and screen layouts with the sketch. A well-designed LCD interface stays readable, responds consistently and makes the device’s current state clear within its modest two-line space.

Previous article Getting Started with an MCP2515 CAN Shield: A Two-Node Bench Network
Next article Calibrating an Arduino Joystick Shield: Centre, Dead Zone and Smooth Control