Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Arduino Based Calculator using Keypad & LCD for Calculation
Arduino Projects

Arduino Based Calculator using Keypad & LCD for Calculation

Mamtaz AlamBy Mamtaz AlamUpdated:August 22, 20224 Comments2 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Arduino Based Calculator using Keypad & LCD
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Arduino Based Calculator using Keypad & LCD:

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.


Circuit Diagram and Requirements:

The circuit diagram is so easy as it can be made either by assembling the circuit directly on the Arduino board or by making the assembled circuit in PCB. The requirements for the circuit are as follows.

C++
1
2
3
4
5
6
7
8
9
1. Arduino Uno Board
2. 16*2 LCD
3. 4*4 Membrane Matrix Keypad
4. 1 kilo ohm resister (2)
5. Reset Switch
6. On/Off Switch
7. 1 kilo ohm Potentiometer
8. 9 volt Battery
10. Bread Board & Connecting Wires

Arduino Based Calculator using Keypad & LCD


Program & Source Code:

The programming is done in Arduino language taking Arduino Uno as reference. You need to add an extra Arduino library file for keypad as #include <Keypad.h >. So download this from adafruit library or just update the library file. After assembling, just upload the source code in Arduino Uno board and enjoy your Arduino Based Calculator



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#include <Keypad.h>
#include <LiquidCrystal.h>
 
// 1. LCD Pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
 
// 2. Keypad Pins
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] = {A2, A3, A4, A5};
byte colPins[Cols] = {2, 3, 4, 5};
Keypad customKeypad = Keypad(makeKeymap(keys), rowPins, colPins, Rows, Cols);
 
// 3. Dot Button
int dot = A0;
int dotFlag = 0;
int dotButton = 0;
 
// 4. Calculator Operators
float num1, num2, fraction;
float total;
char operation, button;
 
// 5. Loading Setup
char input[16];
int n = 1750;
 
void setup()
{
// Initialize dot button as input to Arduino
pinMode(dot, INPUT);
 
// Initialize LCD Size
lcd.begin(16, 2);
 
// LCD Loading Setup Begin
lcd.clear();
lcd.setCursor(3, 0);
lcd.print(“LOADING…”);
for (int i = 0; i < 16; i++)
{
lcd.setCursor(i, 1);
lcd.write(255);
delay(50);
}
lcd.clear();
lcd.setCursor(1, 0);
lcd.print(“Simple Arduino”);
lcd.setCursor(3, 1);
lcd.print(“Calculator”);
delay(n);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Designed By”);
lcd.setCursor(2, 1);
lcd.print(“Alex Newton”);
delay(n);
lcd.clear();
lcd.setCursor(1, 0);
lcd.print(“Alex Newton”);
lcd.setCursor(2, 1);
lcd.print(“how2electronics.com”);
delay(n);
lcd.clear();
lcd.setCursor(1, 0);
lcd.print(“Alex Newton”);
lcd.setCursor(2, 1);
lcd.print(“how2electronics.com”);
delay(n);
lcd.clear();
// LCD Loading Setup End
}
void loop()
{
// First while loop for num1.
while (1)
{
dotButton = digitalRead(dot);
button = customKeypad.getKey();
if (button == ‘C’)
{
dotFlag = 0;
num1 = 0;
num2 = 0;
fraction = 0;
total = 0;
operation = 0;
lcd.clear();
}
else if (dotButton == LOW)
{
dotFlag = 1;
}
else if (button >= ‘0’ && button <= ‘9’)
{
if (dotFlag == 0)
{
num1 = num1 * 10 + (button – ‘0’);
lcd.setCursor(0, 0);
lcd.print(num1);
}
else if (dotFlag == 1)
{
fraction = (button – ‘0’);
num1 = num1 + (fraction / 10);
lcd.setCursor(0, 0);
lcd.print(num1);
dotFlag++;
}
else if (dotFlag == 2)
{
fraction = (button – ‘0’);
num1 = num1 + (fraction / 100);
lcd.setCursor(0, 0);
lcd.print(num1);
dotFlag++;
}
}
else if (button == ‘-‘ || button == ‘+’ || button == ‘*’ || button == ‘/’)
{
operation = button;
dotFlag = 0;
lcd.setCursor(0, 1);
lcd.print(operation);
break;
}
}
// Second while loop for num2.
while (1)
{
dotButton = digitalRead(dot);
button = customKeypad.getKey();
if (button == ‘C’)
{
dotFlag = 0;
num1 = 0;
num2 = 0;
fraction = 0;
total = 0;
operation = 0;
lcd.clear();
break;
}
else if (dotButton == LOW)
{
dotFlag = 1;
}
else if (button >= ‘0’ && button <= ‘9’)
{
if (dotFlag == 0)
{
num2 = num2 * 10 + (button – ‘0’);
lcd.setCursor(1, 1);
lcd.print(num2);
}
else if (dotFlag == 1)
{
fraction = (button – ‘0’);
num2 = num2 + (fraction / 10);
lcd.setCursor(1, 1);
lcd.print(num2);
dotFlag++;
}
else if (dotFlag == 2)
{
fraction = (button – ‘0’);
num2 = num2 + (fraction / 100);
lcd.setCursor(1, 1);
lcd.print(num2);
dotFlag++;
}
}
if (button == ‘=’)
{
domath();
break;
}
}
// Third while loop for ensuring C button is executed after while loop 2.
while (1)
{
button = customKeypad.getKey();
if (button == ‘C’)
{
dotFlag = 0;
num1 = 0;
num2 = 0;
fraction = 0;
total = 0;
operation = 0;
lcd.clear();
break;
}
}
}
void domath()
{
switch (operation)
{
case ‘+’:
total = num1 + num2;
break;
case ‘-‘:
total = num1 – num2;
break;
case ‘/’:
total = num1 / num2;
break;
case ‘*’:
total = num1 * num2;
break;
}
lcd.print(‘=’);
if (operation == ‘/’ && num2 == 0)
{
lcd.print(“ERROR 0 DIV”);
}
else
{
lcd.print(total);
}
}

Check few Arduino Based Projects Here: Arduino Projects

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleECG Display using Pulse Sensor with OLED & Arduino
Next Article Measure Acceleration with Accelerometer ADXL335 & Arduino

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
View 4 Comments

4 Comments

  1. zack6912 on October 27, 2020 10:12 AM

    the pin 15 of the lcd should connect to 5V right? why in the pic the pin 15 is connected to ground?

    Reply
    • Mr. Alam on October 27, 2020 10:13 AM

      It should be connected to 5V.

      Reply
  2. zack6912 on October 27, 2020 10:14 AM

    the pin 15 of the lcd should connect to 5V right? why in the schematic diagram the pin 15 of lcd is connected to the ground?

    Reply
  3. zack6912 on October 27, 2020 12:04 PM

    my lcd screen backlight lights up but not displaying the characters, do you know what goes wrong?

    Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • Interfacing NRF24L01 Transceiver Module with STM32 Tx/Rx
    Interfacing NRF24L01 Transceiver Module with STM32 Tx/Rx
  • IoT Biometric Fingerprint Attendance System using ESP8266
    IoT Biometric Fingerprint Attendance System using ESP8266
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.