#include <LiquidCrystal.h>
int rs = 7;
int en = 8 ;
int d4 = 9 ;
int d5 = 10 ;
int d6 = 11 ;
int d7 = 12 ;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
String msg1 = "Enter 1st number" ;
String msg3 = "Input (+,-,*,/)" ;
String msg2 = "Enter 2nd number" ;
double num1 ;
double num2 ;
String op ;
int dt = 500 ;
double ans ;
void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
lcd.setCursor(0,0);
lcd.print(msg1);
while(Serial.available()==0){}
num1 = Serial.parseFloat();
delay(dt);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(msg2);
while(Serial.available()==0){}
num2 = Serial.parseFloat();
delay(dt);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(msg3);
while(Serial.available()==0){}
op = Serial.readString();
delay(dt);
if(op == "+"){
ans = (num1+num2);
}
if(op == "-"){
ans = (num1-num2);
}
if(op == "*"){
ans = (num1*num2);
}
if(op == "/"){
ans = (num1/num2);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("The answer is :");
delay(dt);
lcd.setCursor(0,1);
lcd.print(ans);
}