#include<Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(5,4,A0,A1,A2,A3);
char keys[4][4] = {
{'1','2','3','+'},
{'4','5','6','-'},
{'7','8','9','*'},
{'*','0','=','/'}
};
byte rowsPin[4] = {13,12,11,10};
byte colsPin[4] = {9,8,7,6};
Keypad pad = Keypad(makeKeymap(keys),rowsPin,colsPin,4,4);
void setup() {
// put your setup code here, to run once:
pinMode(5, OUTPUT);
Serial.begin(9600);
lcd.begin(16,2);
}
String s1="";
void loop() {
// put your main code here, to run repeatedly:
char c = pad.getKey();
if(c != NO_KEY){
//Serial.print(c);
lcd.print(c);
s1=s1+c;
Serial.println(s1);
if(s1.indexOf("=") != -1){
Calc();
}
}
}
void Calc(){
int plus = s1.indexOf('+');
// int p = plus.toInt();
if(plus != -1){
int num1 = s1.substring(0, plus);
// int num2 = s1.substring(plus + 1);
Serial.println(num1);
// int n1 = Int(num1);
// int n2 = num2.toInt();
// lcd.print(n1+n2);
}
}