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.
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
{c++}
#include <ErriezLCDKeypadShield.h>
LCDKeypadShield shield;
Backlight control
Backlight on
{c++}
shield.backlightOn();
Backlight off
{c++}
shield.backlightOff();
Display control
All LCDKeypadShield.h
functions can be used.
Clear display
Set cursor
{c++}
// 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
{c++}
shield.print(F("Push the buttons"));
Button control
Get buttons
{c++}
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
:
{c++}
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