//ENEL 301 - Lab 1
//libraries for LCD screen
#include <LiquidCrystal.h>
#include <Keypad.h>
const int rs=12, en=11, d4=5, d5=4, d6=3, d7=2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', '+'}, //Change A,B,C,D to operations and * to C (clear)
{'4', '5', '6', '-'},
{'7', '8', '9', 'x'},
{'C', '0', '=', '/'}
};
byte rowPins[ROWS] = {14, 15, 16, 17};
byte colPins[COLS] = {18, 19, 20, 21};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.begin(16,2); //setup of lcd with rows, cols of screensize
lcd.print("hello");
}
void loop() {
// put your main code here, to run repeatedly:
char customKey = customKeypad.getKey();
//entering numbers prior to operations
if(customKey != ('+'||'-'||'x'||'/')){
int displayCol = 0;
while (displayCol < 4){
lcd.setCursor(displayCol,0);
lcd.print(customKey);
}
}
/*if (customKey){
//Serial.println(customKey);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(customKey);
}*/
}