#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 = 0;
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 );
void setup(){
lcd.init(); // display initialization
lcd.clear();
lcd.backlight(); // activate the backlight
}
void loop()
{
char key = keypad.getKey();
if(key) //press a key on the 4x4 matrix keypad
{
lcd.print(key);
C++;
if(C>15)
{
lcd.setCursor(C1, R1);
lcd.print(key);
C1++;
}
if(C1>16)
{
lcd.clear();
C=0;
R=0;
}
if(C==0)// && R==0)
{
lcd.print(key);
C++;
}
}
}
Here When I use to press keys on keypad =>
- It starts printing from location (0,0) to (15,0)
- Then gets switch to Row 1 from (0,1) to (15,1)
- Then Screen gets clear !!
At this point I want to start the above 3 steps of function to continue the printing
But here in my code :
After clear screen , the keys are getting printed on a single location (0,0) displaying one key at a time only and it is not proceeding to (1,0) , (2,0) . . . . and so on like that !!!!!
Please help me in getting this . .