/**
Arduino Calculator
Copyright (C) 2020, Uri Shaked.
Released under the MIT License.
*/
#include <LiquidCrystal.h>
#include <Keypad.h>
#include <Servo.h>
/* Display */
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
/* Keypad setup */
const byte KEYPAD_ROWS = 4;
const byte KEYPAD_COLS = 3;
byte rowPins[KEYPAD_ROWS] = {5, 4, 3, 2};
byte colPins[KEYPAD_COLS] = {A3, A2, A1};
char keys[KEYPAD_ROWS][KEYPAD_COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, KEYPAD_ROWS, KEYPAD_COLS);
uint64_t value = 0;
void showWelcomeMessage() {
lcd.print("Meu Amigo");
lcd.setCursor(0, 1);
lcd.print("Andre Soratto");
delay(1000);
}
void updateCursor() {
if (millis() / 250 % 2 == 0 ) {
lcd.cursor();
} else {
lcd.noCursor();
}
}
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
showWelcomeMessage();
lcd.clear();
lcd.cursor();
lcd.setCursor(0, 0);
armBombRoutine();
}
String armBombRoutine() {
lcd.print("Pressione * para");
lcd.setCursor(1,1);
lcd.print("armar a bomba");
}
String inputBombCode() {
lcd.print("Inserir codigo:");
lcd.setCursor(5, 1);
lcd.print("[____]");
lcd.setCursor(6, 1);
String result = "";
while (result.length() < 4) {
char key = keypad.getKey();
if (key >= '0' && key <= '9') {
lcd.print('*');
result += key;
}
}
return result;
}
String memory = "";
String current = "";
void processInput(char key) {
if(key == '#'){
lcd.clear();
lcd.setCursor(1, 0);
lcd.print(" ");
}
lcd.print(key);
}
void loop() {
updateCursor();
char key = keypad.getKey();
if (key) {
processInput(key);
}
}