Professional Documents
Culture Documents
Basic Calculator
Basic Calculator
e
=
(
f
s
×
P
)
2
Basic Calculator
2019/2020
Calculator
The first solid-state electronic calculator was created in the early 1960s. Pocket-sized
devices became available in the 1970s, especially after the Intel 4004, the first
microprocessor, was developed by Intel for the Japanese calculator company
Busicom. They later became used commonly within the petroleum industry (oil and
gas).
Computer operating systems as far back as early Unix have included interactive
calculator programs such as dc and hoc, and calculator functions are included in
almost all personal digital assistant (PDA) type devices, the exceptions being a few
dedicated address book and dictionary devices.
In addition to general purpose calculators, there are those designed for specific
markets. For example, there are scientific calculators which include trigonometric
and statistical calculations. Some calculators even have the ability to do computer
algebra. Graphing calculators can be used to graph functions defined on the real line,
or higher-dimensional Euclidean space. As of 2016, basic calculators cost little, but
scientific and graphing models tend to cost more.
1
now there are a lot of type and prands for the calculator most of it are cheaper than
what it used to be also any one with basic knowledge of arduino with the help of net
can make one for that in this report i desided to make one from arduino.
• Arduino Uno R3
• Breadbord
• Resistor
• Keypad 4*4
• Potinteometer
• LCD 16*2
these are the main parts used for our basic calculator now the B is for _ ,C is for
+,the B is for * and the A is for the rest are *for rest and #for = in keypad
2
The code for this project:
#include <LiquidCrystal.h>
#include <Keypad.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // setting the expander address, number of lcd
columns, number of lcd rows
long first = 0;
long second = 0;
double total = 0;
int posit = 0 ;
char customKey;
const byte ROWS = 4;
const byte COLS = 4;
void setup(){
lcd.begin(16,2);
lcd.setCursor(5,0);
lcd.setCursor(3,1);
delay(1000);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Baisc Calculator");
lcd.setCursor(4,1);
lcd.print("Arduino");
delay(2000);
lcd.clear(); //clears the LCD screen and positions the cursor in the upper-left corner.
3
}
void loop()
{
customKey = customKeypad.getKey();
switch(customKey)
{
case '0' ... '9': // get first value for calculation
lcd.setCursor(0,0);
first = first * 10 + (customKey - '0');
lcd.print(first);
posit++;
break;
case '+':
first = (total != 0 ? total : first);
lcd.setCursor(posit,0);
lcd.print("+");
posit++;
second = SecondNumber(); // get second number
total = first + second;
lcd.setCursor(1,1);
lcd.print(total);
first = 0, second = 0; // reset the values
posit=0;
break;
case '-':
first = (total != 0 ? total : first);
lcd.setCursor(posit,0);
lcd.print("-");
posit++;
second = SecondNumber();
total = first - second;
lcd.setCursor(1,1);
lcd.print(total);
first = 0, second = 0;
posit=0;
break;
case '*':
first = (total != 0 ? total : first);
lcd.setCursor(posit,0);
lcd.print("*");
4
posit++;
second = SecondNumber();
total = first * second;
lcd.setCursor(1,1);
lcd.print(total);
first = 0, second = 0;
posit=0;
break;
case '/':
first = (total != 0 ? total : first);
lcd.setCursor(posit,0);
lcd.print("/");
posit++;
second = SecondNumber();
lcd.setCursor(1,1);
lcd.print(total);
first = 0, second = 0;
posit=0;
break;
case 'C':
total = 0;
first = 0;
second = 0;
posit = 0;
lcd.clear();
break;
}
}
long SecondNumber()
{
while( 1 )
{
customKey = customKeypad.getKey();
if(customKey >= '0' && customKey <= '9')
{
second = second * 10 + (customKey - '0');
lcd.setCursor(posit,0);
5
lcd.print(second);
}
if(customKey == 'C') {
total = 0;
first = 0;
second = 0;
posit = 0;
lcd.clear();
break;
}
if(customKey == '='){
lcd.setCursor(0,1);
lcd.print("=");
posit = total;
lcd.clear();
lcd.setCursor(0,1);
lcd.print("=");
break;
}
}
return second;}
6
The circuit:
References: