Practical Maker's I2C HD44780 LCD/Keypad Backpack is a basic, inexpensive little LCD backpack that is unique in that it combines a standard 4x3 keypad input with a standard HD44780 LCD. It has all of the necessary housekeeping functions like set cursor, cursor left, cursor right and backspace as well as basic single digit key press input /recognition. All on a single I2C address using the normal Arduino Wire library.
http://www.practicalmaker.com/products/lcds/i2c-hd44780-lcdkeypad-backpack-assembled
I whipped up a little test code to demonstrate cursor and backspace functionality. Andrew Oke posted it on Practical Maker and I posted it as well on Appiphania.com.
/* Practical Maker I2C HD44780 LCD/Keypad Backpack - test
Author: Jim Winburn - Appiphania.com July 25, 2011
This little snippet of code loads a 16x2 lcd
with "Key: " at cursor position 0,0 then prints
keypress input beginning at cursor postion 0,4
"*" will enter a distructive backspace in the LCD
and "#" will cursor right
Note: uncomment Serial.begin and Serial.print and Serial.println
to test with Arduino IDE Serial Monitor
*/
#include <Wire.h>
#include <I2CLCD.h>
byte a;
byte b;
I2CLCD lcd = I2CLCD(0x12, 16, 2); //set for 16X2 LCD
void setup(){
lcd.init();
//Serial.begin(9600); //used to verify keys - comment out if not needed
lcd.clearBuffer(); //clear buffer
lcd.blinkOn(); // turn blinking cursor on
lcd.setCursor(0,0); // position cursor
lcd.write("Key: "); // test txt
lcd.setCursor(0,4); //set cursor to start after "Key: "
}
void loop(){
a = lcd.getKey(); //Read key press
if (a != b) { //check buffer
if (a != 0x00) { //ignore get key return of 0x00
if (a == 0x2A) { //backspace - cursor left and clear character on *
lcd.backspace();
} else if (a == 0x23) { //cursor right on #
lcd.cursorRight();
} else {
lcd.write(a); //write key to cursor location on LCD
//Serial.print(a); //used to verify keys - comment out if not needed
//Serial.println(); //used to verify keys - comment out if not needed
}
}
b = a;
} // main test - if(a = !=b)
}
https://www.youtube.com/watch?v=d6ZqQpEYDyw