Skip to content

Erriez/ErriezLCDKeypadShield

Repository files navigation

Erriez LCD Keypad Shield library for Arduino

Build Status

This is a LCD Keypad Shield library for Arduino which supports the following features:

  • 2x16 LCD using LiquidCrystal.h.
  • 5 pushbuttons connected to analog pin A0.
  • Button debouncing.
  • Backlight control (on/off).

Hardware

Any Arduino board, tested on Arduino UNO.

LCD Keypad Shield

Pins

2x16 LCD pins UNO/Leonardo/Mega2560
RS 8
EN 9
D0 4
D1 5
D2 6
D3 7
Backlight 10

Example

Arduion IDE | Examples | Erriez LCDKeypadShield:

Documentation

Usage

Initialization

#include <ErriezLCDKeypadShield.h>

LCDKeypadShield shield;

Backlight control

Backlight on

shield.backlightOn();

Backlight off

shield.backlightOff();

Display control

All LCDKeypadShield.h functions can be used.

Clear display

shield.clear();

Set cursor

// First character first line
shield.setCursor(0, 0);

// First character second line
shield.setCursor(0, 1);

// Last character second line
shield.setCursor(15, 1);

Print text

shield.print(F("Push the buttons"));

Button control

Get buttons

LCDButtons button = shield.getButtons();
// Returned button enum:
//   ButtonNone
//   ButtonRight
//   ButtonUp
//   ButtonDown
//   ButtonLeft
//   ButtonSelect

Improve response

The resistors may be different for each board to read the analog key value. To improve response, experiment by updating the analogKey values in: src\ErriezLCDKeypadShield.cpp:

if (analogKey < 50) { /* <= Incread/decrease value 50 */
    key = ButtonRight;
} else if (analogKey < 200) { /* <= Incread/decrease value 200 */
    key = ButtonUp;
} else if (analogKey < 350) { /* <= Incread/decrease value 350 */
    key = ButtonDown;
} else if (analogKey < 500) { /* <= Incread/decrease value 500 */
    key = ButtonLeft;
} else if (analogKey < 750) { /* <= Incread/decrease value 750 */
    key = ButtonSelect;
} else {
    key = ButtonNone;
}

Library dependencies

  • Arduino's build-in LiquidCrystal library.

Library installation

Please refer to the Wiki page.

Other Arduino Libraries and Sketches from Erriez