#include <LiquidCrystal.h>
#include <Keypad.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
const int ROW_NUM = 4; //four rows
const int COLUMN_NUM = 4; //four columns
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','2','3', '+'},
{'4','5','6', '-'},
{'7','8','9', '*'},
{'.','0','=', '/'}
};
byte pin_rows[ROW_NUM] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {A3, A2, A1, A0}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
String noOfElements;
int cursorColumn = 0;
int cursorRowInput = 1;
int n;
void setup(){
Serial.begin(9600);
//input_password.reserve(32); // maximum input characters is 33, change if needed
lcd.begin(16, 2); // set up number of columns and rows
lcd.setCursor(cursorColumn, 0);
lcd.print("Enter#elements: ");
//lcd.setCursor(0, 0); // move cursor to (0, 0)
//lcd.print("Arduino"); // print message at (0, 0)
//lcd.setCursor(2, 1); // move cursor to (2, 1)
//lcd.print("GetStarted.com"); // print message at (2, 1)
}
void loop(){
char key = keypad.getKey();
if (key){
//punta sa function na mag coconvert sa inenter to integer or double
Serial.println(key);
lcd.setCursor(cursorColumn, 1); // move cursor to (cursorColumn, 1 ) for input
lcd.print(key); // print key at (cursorColumn, 0)
cursorColumn++;
if(key == '/') {
noOfElements = ""; // clear input noOfElements
}
else if(key == '=') {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Enter#");
Serial.println(noOfElements);
noOfElements = ""; // clear input noOfElements
} else {
noOfElements += key;// append new character to input noOfElements string
}
}
}