Simple Calculator
Simple Calculator
AimMake a simple calculator using matrix keypad and LCD display. Extend this calculator to
Implement the SQRT() function. Finally display answer in Hindi font also.
ApparatusArduino, 4x4 Matrix Keypad, 16x2 LCD, potentiometer, Breadboard, Wire Cutter, Connecting
Wires, Male-Female Jumper Wires, Resistors.
Challenges Faced
There is limit of calculation in this calculator, because of it we cant get answer greater than
2^15 or 32768.
The simple calculator (+, -, x, /) needs two inputs but in square root operation, we can only give
one input.
The matrix keypad have only 16 keys, so for sqrt operation we have to replace one key
operation.
In Hindi fonts of numbers, we have to make extra loop to get the correct response when the
output greater than one digit.
Circuit Diagram-
Figure 1. (a) Circuit Diagram for Arduino Matrix Calculator [1] (b) Our Circuit
Flow Chart-
Start
Input a
Operation
NO
Input b
sqrt()
YES
NO
Ans=sqrt(a)
NO
NO
YES
YES
Ans=a-b
Ans=a+b
YES
Ans=axb
YES
b=0
NO
Ans=a/b
Not Defined
Ans
Stop
if (op == '+'){
ans = num1.toInt() + num2.toInt();
}
else if (op == '?'){
ans = sqrt(num1.toInt()) ;
}
else if (op == '*'){
ans = num1.toInt() * num2.toInt();
}
else if (op == '/') {
ans = num1.toInt() / num2.toInt();
}
lcd.clear();
lcd.setCursor(15,0);
lcd.autoscroll();
if (op == '/' && num2.toInt() == 0 ) {
lcd.print ("Absurd");
}
else {
lcd.print(ans);
int nnem;
int i=15;
while(ans!=0){
lcd.setCursor(i,1);
nnem=ans%10;
ans=ans/10;
lcd.write(nnem);
i=i-1;
}
}
lcd.noAutoscroll();
}
else if (key != NO_KEY && key == 'X'){
lcd.clear();
valOnePresent = false;
final = false;
num1 = "";
num2 = "";
ans = 0;
op = ' ';
}
}
Results and Conclusions1. We can implement calculator operations using Arduino and Matrix Keypad.
2. There is a limit for calculations in this Calculator. We cant get the result more than 2^15.
3. We can only give eight characters for Hindi number fonts, so we neglect 3 and 0 because they
are same in both fonts.
References[1] http://www.vathsav.com/post/arduino_calculator.html
[2] https://github.com/vathsav/Arduino/blob/master/calculator/calculator.ino
[3] https://omerk.github.io/lcdchargen/
[4] https://www.arduino.cc/en/Reference/LiquidCrystal