Hello, There !
In one of the my project I am trying to save the data of key pressed (3x4 Keypad) in variable using arduino mega2560 but unable to do that. I want to store data like, if i pressed "4356789" that data will store in one variable and then i will work on that variable. For the testing purpose i am trying to display it on LCD . Can anyone tell me how to do that?
Source code of keypad:
#include <LiquidCrystal.h>
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'-','0','+'}
};
byte rowPins[ROWS] = {29,30,31,32};
byte colPins[COLS] = {26,27,28};
LiquidCrystal lcd(38,37,36,35,34,33);
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() {
lcd.begin(16, 4);
lcd.setCursor(0,0);
}
void loop() {
char key = keypad.getKey();
if (key) {
lcd.print(key);
}
}