Untitled 2

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include <LiquidCrystal.

h>

#include <Keypad.h>
const int rs = 12, en = 11, d4 = 9, d5 = 8, d6 = 7, d7 = 6;
const byte rows = 4;
const byte cols = 4;

char x, y, z;
char oper;
char customkey;
// these are arrays just to configur eouyr keypad
char hexakeys[rows][cols]= {
{'1','2','3','+'},
{'4','5','6','-'},
{'7','8','9','*'},
{'*','0','#','/'},
};
// how our keypad is connected to arduino
byte rowpins[rows] = {A0,A1,A2,A3};
byte colpins[cols] = {A4,A5,2,3};

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);


Keypad customKeypad = Keypad (makeKeymap(hexakeys),rowpins,colpins,rows,cols);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
Serial.begin(9600);
}

void loop() {

lcd.setCursor(0, 0);
lcd.print("what is the 1st No");
x = customKeypad.getKey();
if(x != )
lcd.clear();

lcd.print("what is the 2nd No");


y = customKeypad.getKey();
if(y) y = y;
lcd.clear();

lcd.print("what is the oper");


oper = customKeypad.getKey();
if(oper) oper = oper;
lcd.clear();

if(oper == '+') z = x+y;


if(oper == '-') z = x-y;
if(oper == '*') z = x*y;
if(oper == '/') z = x/y;

Serial.print(x);
// lcd.print(x);
// lcd.print(y);
// lcd.print(oper);
lcd.print(z);
delay(5000);
// lcd.setCursor(0, 0);
// lcd.print("Your answer is ");
// lcd.setCursor(0, 1);
// lcd.print(z);
// delay(2000);
// lcd.clear();

}
/* {"1","2","3","A"},
{"4","5","6","B"},
{"7","8","9","C"},
{"*","0","#","D"},*/

You might also like