LCD Keypad shield on Arduino
Project note — LCD Keypad shield V1.0
1. Schematic
The LCD Keypad shield is developed for Arduino compatible boards, to provide a user-friendly interface that allows users to go through the menu, make selections etc. It consists of a 1602 white character blue backlight LCD and 5 pushbuttons that form a joystick-style keypad.
2. LCD Interface
The LCD interaface uses HD44780D 4-bit compatible interface. In order to preserve the SPI interface for future use, a different set of IO pins is used. The following diagram shows the IO pins used to drive the LCD, you can modify the original 4bit LCD libaray [download here] or you can download the modified 4-bit LCD library [download here] .

int USING_RW = false;
//RS, RW and Enable can be set to whatever you like
int RS = 8;
int RW = 11;
int Enable = 9;
//DB should be an unseparated group of pins
int DB[] = {4, 5, 6, 7}; //wire these to DB4~7 on LCD.
3. Keypad Interface
The joystick style keypad consists of 5 keys — select, up, right, down and left. To save the digital IO pins, the keypad interface only uses one ADC channel. The key value is read through a 5 stage voltage divider as shown below.
When a key is pressed, the ADC reads the voltage value through the voltage divider; the the voltage value is compared to the voltage threshold values stored in an array to identify which key is pressed.
int adc_key_val[5] ={30, 150, 360, 535, 760 };
int NUM_KEYS = 5;
....
void loop()
{ adc_key_in = analogRead(0); // read the value from the
sensor digitalWrite(13, HIGH);
key = get_key(adc_key_in); // convert into key press
if (key != oldkey) // if keypress is detected {
delay(50); // wait for debounce time
adc_key_in = analogRead(0); //read the value from the sensor
key = get_key(adc_key_in); // convert into key press
if (key != oldkey) {
oldkey = key;
if (key >=0){
lcd.cursorTo(2, 0); //line=2, x=0
lcd.printIn(msgs[key]);
}
}
}
digitalWrite(13, LOW); }
4. Examples
Two exmaples for LCD keypad shield are included in the midified LCD 4-bit library [download here]
- Example 1 — Joystick keypad test routine, keypress shown on the LCD screen
- Example 2 — Temperature measurenemt, using prototype shield & LCD keypad shield
5. Links & Downloads
- LCD keypad shield schematic V1.1
- Original LCD 4-bit library
- Modified LCD 4-bit libaray with examples
- New Project note - LCD Smartie on Arduino , communicate with your PC using the LCD keypad shield.
Tags: Arduino, Arduino projects, joystick, keypad, LCD, shield

