#include <Keypad.h>
int attempts = 1;
float i;
long pass_input = 0;
int pass;
int temp;
char key;
const byte ROWS = 4;
const byte COLS = 4;
byte rowPins[ROWS] = {14, 15, 16, 17};
byte colPins[COLS] = {A3, A2, A1, A0};
char keys[ROWS][COLS] = {
{'1', '2', '3', '+'},
{'4', '5', '6', '-'},
{'7', '8', '9', '*'},
{'.', '0', '=', '/'}
};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
int Password() {
pass_input = 0;
i = 3.00001;
while (i >= 0) {
key = keypad.waitForKey();
if (((key - 48) >= 0) && ((key - 48) <= 9)) {
temp = key - 48;
pass_input += temp * pow(10,i);
i -= 1;
}
}
return pass_input;
}
void setup() {
Serial.begin(9600);
}
void loop() {
while (attempts <= 3) {
pass = Password();
}
}
/// END ///