#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd();
const byte KEYPAD1_ROWS = 4;
const byte KEYPAD1_COLS = 4;
byte rowPins1[KEYPAD1_ROWS] = {7, 6, 5, 4};
byte colPins1[KEYPAD1_COLS] = {3, 2, 1, 0};
char keys1[KEYPAD1_ROWS][KEYPAD1_COLS] = {
{'1', '2', '3', '+'},
{'4', '5', '6', '-'},
{'7', '8', '9', '*'},
{'.', '0', '=', '/'}
};
Keypad keypad1 = Keypad(makeKeymap(keys1), rowPins1, colPins1, KEYPAD1_ROWS, KEYPAD1_COLS);
const byte KEYPAD2_ROWS = 4;
const byte KEYPAD2_COLS = 4;
byte rowPins2[KEYPAD2_ROWS] = {14, 15, 16, 17};
byte colPins2[KEYPAD2_COLS] = {18, 19, 20, 21};
char keys2[KEYPAD2_ROWS][KEYPAD2_COLS] = {
{"^", "±", "!", "sin"};
{"cos", "tg", "ctg", "1/x"};
{ "log","√","_","_"};
{"_","_","_","_"}
};
Keypad keypad2 = Keypad(makeKeymap(keys2), rowPins2, colPins2, KEYPAD2_ROWS, KEYPAD2_COLS);
uint64_t value = 0;
void showSpalshScreen() {
lcd.print("GoodArduinoCode");
lcd.setCursor(3, 1);
String message = "Calculator";
for (byte i = 0; i < message.length(); i++) {
lcd.print(message[i]);
delay(50);
}
delay(500);
}
void updateCursor() {
if (millis() / 250 % 2 == 0 ) {
lcd.cursor();
} else {
lcd.noCursor();
}
}
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
showSpalshScreen();
lcd.clear();
lcd.cursor();
lcd.setCursor(1, 0);
}
char operation = 0;
String memory = "";
String current = "";
uint64_t currentDecimal;
bool decimalPoint = false;
double calculate(char operation, double left, double right) {
switch (operation) {
case '+': return left + right;
case '-': return left - right;
case '*': return left * right;
case '/': return left / right;
case '^': return pow(left, right);
case '!': return pow(left, right);
case '^': return pow(left, right);
case '^': return pow(left, right);
"±", "!", "sin"
}
}
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}