/*Write a program to interface LCD and keypad (4 X 4) , to exhibit the
functionality of a basic calculator.
1 2 3 4
5 6 7 8
9 0 + - */
// / * Clear Enter
#include <LiquidCrystal.h>
#include <Keypad.h>
int key;
int rPins;
int cPins;
byte ROWS=4;
byte COLS=4;
char [ROWS][COLS]={
{'1','2','3','4'},
{'5','6','7','8'},
{'9','0','+','-'},
{'/','*','clear','enter'}
};
Keypad keypad =Keypad(makeKeymap(key),rPins,cPins,ROWS,COLS);
int rs=12,en=11,d4=5,d5=4,d6=3,d7=2;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
void setup() {
Serial.begin(9600);
lcd.begin(16,2);
lcd.print("hello");
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
char key=keypad.getKey();
if(key!=NO_KEY){
Serial.println(key);
}
lcd.setCursor(0,1);
}