#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
const byte ROWS = 4;
const byte COLS = 4;
int change=1,c=0;
float x=0,y=0,r=0;
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', '+'},
{'4', '5', '6', '-'},
{'7', '8', '9', '*'},
{'E', '0', 'C', '/'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd(0x27, 20 , 4);
void setup(){
lcd.init();
lcd.backlight();
}
void loop(){
char customKey = customKeypad.getKey();
///input///
if(customKey)
{
if(customKey='E')
c++;
if(c=0)
if(customKey='1')
x=(x*10)+1;
if(customKey='2')
x=(x*10)+2;
if(customKey='3')
x=(x*10)+3;
if(customKey='4')
x=(x*10)+4;
if(customKey='5')
x=(x*10)+5;
if(customKey='6')
x=(x*10)+6;
if(customKey='7')
x=(x*10)+7;
if(customKey='8')
x=(x*10)+8;
if(customKey='9')
x=(x*10)+9;
if(customKey='0')
x=(x*10)+0;
}
////display////
if(change=1)
{
if(c=0)
{
lcd.setCursor(0,0);
lcd.print("");
lcd.print(x);
}
if(c=1)
{
lcd.setCursor(0,1);
lcd.print(" ");
lcd.print(customKey);
}
if(c=2)
{
lcd.setCursor(0,2);
lcd.print(" ");
lcd.print(y);
}
if(c=3)
{
lcd.setCursor(0,3);
lcd.print(" ");
lcd.print("=");
lcd.print(r);
}
}
delay(50);
}