What is Calculator?
A calculator is a device that performs arithmetic operations on numbers. Basic calculators can do only addition, subtraction, multiplication and division mathematical calculations.
However, more sophisticated calculators can handle exponential operations, square roots, logarithms, trigonometric functions and hyperbolic functions. Internally, some calculators perform all these functions by repeated addition processes.
Growth of Calculators
Most calculators these days require electricity to operate or are battery-powered calculators. Calculators work by performing programmed functions based on numerical inputs.
Before the electronic calculator (circa 1970), a more primitive calculator, the slide rule, was commonly used. It consisted of a slat of wood called the slide that could be moved in and out of a reinforced pair of slats. Both the slide and the outer pair of slats had calibrated numerical scales.
A movable, transparent sleeve called the cursor was used to align numerals on the scales. The slide rule did not require any power source, but its precision was limited, and it was necessary to climb a learning curve to become proficient with it.
One of the most primitive calculators, the abacus, is still used in some regions of the Far East. The abacus acts as an adding machine that uses groups of beads to denote numbers.
Arduino based Calculator using Keypad and LCD Display.
A simple Arduino Based Calculator using Keypad & LCD for Solving Mathematical Calculations can be easily implemented using Arduino, LCD, and Keypad. A simple mathematical calculation like Addition, Subtraction, Multiplication, and Division can easily do using this project.
A calculator is a machine that allows people to do math operations more easily. For example, most calculators will add, subtract, multiply, and divide.
The 16*2 LCD is capable of solving mathematical problems up to 16 digits without delay and fast processing. Even the Arduino program is easy and is almost like a simple C program, merely based on a simple formula for addition, subtraction, multiplication, and division. So let’s implement this simple Project.
Parts List ( Affiliate links of India ) :-
1. Arduino Uno : https://amzn.to/3fxA4JZ
2. LCD Display : https://amzn.to/3AH4kJQ
3. Jumper wires : https://amzn.to/2WmLSI2
4. Keypad 4 x 4 : https://amzn.to/3uneMpC
5. Breadboard : https://amzn.to/3yGJ0qi
6. 10K potentiometer : https://amzn.to/3OFAeOx
Steps to make this project:
1. Gather all components like Arduino Uno, Keypad 4 x 4, LCD Display, Jumper wires etc.
2. Do connections of LCD Display.
" If you don't know How to do connections of LCD Display, then click on this link of How to Connect 16 x 2 LCD display"
3. Then Take Keypad 4 x 4 and connect Male to Male Jumper Wires to it.
4. Do the connections from Circuit Diagram.
5. Upload the Arduino Code.
Your Arduino Calculator is ready.
Circuit Diagram:-
Arduino Code:-
// https://www.youtube.com/channel/UCaXI2PcsTlH5g0et67kdD6g //
// Arduino Calculator with LCD Display //
// By MOHD SOHAIL //
#include <LiquidCrystal.h>
#include <Keypad.h>
LiquidCrystal lcd(0, 1, 2, 3, 4, 5);
const byte ROWS = 4;
const byte COLS = 4;
char keys [ROWS] [COLS] = {
{'1', '2', '3', '+'},
{'4', '5', '6', '-'},
{'7', '8', '9', '*'},
{'C', '0', '=', '/'}
};
byte rowPins[ROWS] = {13,12,11,10};
byte colPins[COLS] = {9,8,7,6};
Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
boolean presentValue = false;
boolean next = false;
boolean final = false;
String num1, num2;
int answer;
char op;
void setup()
{
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(" Arduino ");
lcd.setCursor(0,1);
lcd.print(" Calculator ");
delay(3000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" by EIF ");
lcd.setCursor(0,1);
lcd.print(" SOHAIL ");
delay(3000);
lcd.clear();
}
void loop(){
char key = myKeypad.getKey();
if (key != NO_KEY && (key=='1'||key=='2'||key=='3'||key=='4'||key=='5'||key=='6'||key=='7'||key=='8'||key=='9'||key=='0'))
{
if (presentValue != true)
{
num1 = num1 + key;
int numLength = num1.length();
lcd.setCursor(15 - numLength, 0); //to adjust one whitespace for operator
lcd.print(num1);
}
else
{
num2 = num2 + key;
int numLength = num2.length();
lcd.setCursor(15 - numLength, 1);
lcd.print(num2);
final = true;
}
}
else if (presentValue == false && key != NO_KEY && (key == '/' || key == '*' || key == '-' || key == '+'))
{
if (presentValue == false)
{
presentValue = true;
op = key;
lcd.setCursor(15,0);
lcd.print(op);
}
}
else if (final == true && key != NO_KEY && key == '='){
if (op == '+'){
answer = num1.toInt() + num2.toInt();
}
else if (op == '-'){
answer = num1.toInt() - num2.toInt();
}
else if (op == '*'){
answer = num1.toInt() * num2.toInt();
}
else if (op == '/'){
answer = num1.toInt() / num2.toInt();
}
lcd.clear();
lcd.setCursor(15,0);
lcd.autoscroll();
lcd.print(answer);
lcd.noAutoscroll();
}
else if (key != NO_KEY && key == 'C'){
lcd.clear();
presentValue = false;
final = false;
num1 = "";
num2 = "";
answer = 0;
op = ' ';
}
}
0 Comments