#include <LiquidCrystal.h>
int rs = 7;
int en = 8;
int d4 = 9;
int d5 = 10;
int d6 = 11;
int d7 = 12;
float primerNum;
float segundoNum;
float respuesta;
String op;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.begin(16, 2);
Serial.println("\n");
}
void loop() {
//
lcd.setCursor(0, 0);
lcd.print("Primer Num es: ");
// while (Serial.available() == 0) {}
primerNum = Serial.parseFloat();
Serial.println(primerNum);
delay(500);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Segundo Num es: ");
while (Serial.available() == 0) {
}
segundoNum = Serial.parseFloat();
Serial.println(segundoNum);
delay(500);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Introduce(+,-,*,/)");
while (Serial.available() == 0) {
}
op = Serial.readString();
if (op == "+") {
respuesta = primerNum + segundoNum;
}
if (op == "-") {
respuesta = primerNum - segundoNum;
}
if (op == "*") {
respuesta = primerNum * segundoNum;
}
if (op == "/") {
respuesta = primerNum / segundoNum;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(primerNum);
lcd.print(op);
lcd.print(segundoNum);
lcd.print(" = ");
lcd.print(respuesta);
lcd.setCursor(0, 1);
lcd.print("Gracias");
delay(5000);
lcd.clear();
}
/*
VSS->GND
VDD->5V
V0->sig
RS->pin 7 Arduino
E->pin 8 Arduino
D4->pin 9 Arduino
D5->pin 10 Arduino
D6-> pin 11 Arduino
D7->pin 12 Arduino
A->5V
K->GND
*/