#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
String rzeichen = "";
String ergebnisz = "";
float zahl1 = 0;
float zahl2 = 0;
float ergebnis = 0;
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27,16,2);
const uint8_t ROWS = 4;
const uint8_t COLS = 4;
char keys[ROWS][COLS] ={
{ '1', '2', '3', '+' },
{ '4', '5', '6', '-' },
{ '7', '8', '9', '*' },
{ '.', '0', '=', '/' }
};
uint8_t colPins[COLS] = { 17, 5, 18, 19 }; // Pins connected to C1, C2, C3, C4
uint8_t rowPins[ROWS] = { 15, 2, 4, 16 }; // Pins connected to R1, R2, R3, R4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
LCD.init();
LCD.backlight();
LCD.setCursor(1,0);
LCD.print("Calculator_v2");
delay(1000);
LCD.init();
LCD.setCursor(0,0);
}
void loop(){
char key = keypad.getKey();
if(key != NO_KEY){
Serial.println(key);
zahl1 = zahl1 * 10 + (key-'0');
LCD.setCursor(0,0);
LCD.print(zahl1);
}
}