#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <Keypad.h>
const int ROW_NUM = 4; //four rows
const int COLUMN_NUM = 4; //four columns
char keys[ROW_NUM][COLUMN_NUM] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
int R = 0;
int C = 0;
int R1 = 1;
int C1 = 1;
int patch=1;
byte pin_rows[ROW_NUM] = {A15, A14, A13, A12}; //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {A11, A10, A9, A8}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
// #define Single_long_click_duration 10000
void setup() {
lcd.init(); // display initialization
lcd.clear(); // clear the screen fully
lcd.backlight(); // activate the backlight
}
void loop()
{
lcd.setCursor(C1, R1);
char key = keypad.getKey();
if (key)
{
switch(key)
{
case '1':
lcd.print(key);//something
C1++;
if(C1>3)
{
C1=3;
}
break;
case 'B':
if(C1>1)
{
C1--;
if(C1<1)
C1=1;
lcd.setCursor(C1,R1);
lcd.print(' ');
}
break;
}
}
Here I am using Key 'B' as backspace function to erase the content of key '1'
key '1' is coded in a way to print up to 3 places maximum from (1,1) to (3,1) location as observed in code above
For single digit '1' at (1,1) & also for double digit '1' it works properly
But for 111 its erasing firstly '1' at (2,1) and then '1' at (1,1) but don't use to effect '1' at (3,1) location