Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Making Two digit calculator with Arduino uno , 16×2 lcd and 4×4 numeric keypad

By EG Projects July 3, 2019

This tutorial is about making arduino calculator. We will build two digit arduino calculator using arduino uno, 4×4 numeric keypad and 16×2 lcd. This particular arduino calculator can perform six functions addition, subtraction, multiplication, division, power and reminder. Code is easy to understand but its lengthy. If you are already familiar with the arduino coding syntax, you can easily understand the code below. If you are not than take some tutorials to become familiar with arduino language syntax. 

Arduino calculator project requirements

  • Arduino uno     (Microcontroller)
  • 4×4 Keypad      (Taking input from Users)
  • 16×2 Lcd           (Displays Result)
  • Potentiometer   (Setting Lcd Contrast)​

Arduino uno is used as microcontroller in the project. Arduino takes the input from user and after analyzing the instructions produces output. The output is than displayed on 16×2 lcd. 4×4 numeric keypad is used as input. User presses the buttons on keypad to give input to arduino calculator. Arduino calculator takes two digits and an operator as input. Arduino calculator then identifies the operator, computes results according to the operator and then displays the result on 16×2 lcd screen.

Lcd 16×2 is interfaced in 4-bit mode with arduino uno. Arduino pins D13, D12, D11, D10, D9 and D8 are occupied by 16×2 lcd. 4×4 Keypad rows are connected to pins  D4, D5, D6 & D7 of arduino uno. Coulombs of keypad are connected to pins D0, D1, D2 & D3 of arduino uno. 

The lay out arduino calculator keypad is given below. All the six mathematics functions which our calculator can perform are mapped on the keypad.
Note: You may see buttons text printed on your 4×4 keypad different then the keypad shown below. Actually buttons text did not mean any thing. What we define or map on keypad keys at controller side will be performed by the keypad. So in our case i lay out the mapping on keypad shown below. Instead of power and reminder operator you will find “On” and “=” printed on keypad in most of the cases. 

Arduino calculator keypad

Arduino calculator keypad

Its not possible to explain how to interface 16×2 lcd with arduino uno? In what modes lcd 16×2 can be interfaced with arduino? and How to operate it. Its also not possible to explain the interface of 4×4 numeric keypad with arduino uno. If you seeking the results of above questions i recommend you to take the tutorials listed below. These tutorials are about interfacing of 16×2 lcd and 4×4 keypad with arduino. 

  • How to interface 16×2 lcd in 4-bit mode with arduino​​

The tutorials above are very important. If you take them its become easier for you to understand the  arduino calculator code below. If you already know how to interface character lcd (16×2) and 4×4 keypad with arduino, you can skip the above tutorials. Circuit Diagram of the project is given below.                  ​

Arduino calculator (arduino uno, 16x2 lcd, 4x4 numeric keypad)circuit diagram

Arduino calculator (arduino uno, 16×2 lcd, 4×4 numeric keypad)circuit diagram

Calculator with Arduino uno, 16x2 lcd and 4x4 keypad--Circuit Diagram

Calculator with Arduino uno, 16×2 lcd and 4×4 keypad–Circuit Diagram

Arduino calculator code

​First off all in the code i exported Liquid Crystal library. Liquid Crystal library contains predefined functions which could be used in arduino code to easily interface and operate 16×2 lcd with arduino uno. I am interfacing 16×2 lcd in 4-bit mode with arduino uno. Comming to wards the key functions which are part of the arduino calculator code. Each function name with the functions they perform are listed below.

  • int  getKey ()                    is taking inputs, digits from keypad.
  • char getOper()                 is taking input , Operator from keypad. 
  • void result (float result)  Displaying result on lcd. ​
Next two statements define rows and coulombs of keypad. key1 is an integer variable, it stores first digit which is inputted by user using 4×4 keypad. key2 is an another integer variable, it stores second digit inputted by the user. oper is character variable it stores the operator inputted by user through keypad.

In setup() function, lcd.begin(16,2) statement initializes the lcd. This tells the 16×2 lcd controller to begin operation. Command passes some constraints to controller and tells it to operate in this mode with 16 coulombs and 2 rows  After wards rows of keypad are initialized as output and coulombs are initialized as input.

The first string that appears on the screen when you download the code in arduino uno board and run it is “CALCULATOR!!!!“. It will be displayed on the first row of 16×2 character lcd. It will remain on the screen for 4 seconds delay(4000) statement means stop execution of instructions for 4 seconds. After 4 seconds “CALCULATOR!!!” string vanishes and a new text string will prompt on lcd. New text will be “Enter 1 no = “. Now you have to enter the first digit using keypad. After you enter the first number second text will appear on 16×2 lcd asking for second digit “Enter 2 no = “. At this point you have to enter the second digit. Than a third string appears on lcd asking to input operator “Operator = “. You now must select the operator from keyboard. As soon as you enter the operator result will be displayed on lcd with out any further delay. Result of a particular inputs remain on lcd for 5 seconds. After 5 seconds lcd clears all the text displayed on it and starts from beginning. Taking digits, operator etc and producing results. ​​

More calculator projects using other different types microcontrollers are listed below. Each microcontroller calculator project contains free source code and circuit diagram of the project.    

Calculator with Pic Microcontroller

Calculator with 8051 Microcontroller

Watch the Project Video Here…..

Download the Project Files that contain code and .ino file of the project. If you have any questions regarding code or circuit diagram, Please write them in the comments section below. Give us your feed back on the project.

Calculator using Arduino Uno Files 


Filed Under: Arduino Projects, Microcontroller Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Power Efficiency
Discover proven strategies for power conversion, wide bandgap devices, and motor control — balancing performance, cost, and sustainability across industrial, automotive, and IoT systems.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions.

  • Can anyone please help me with this single board computer?
  • Anyone successfully communicated to the BlueNRG-M0 module on the B-L4S5I-IOT01A board
  • How to Build an Audio Tone Control?
  • Current version of LTspice not working on Windows 11?
  • Addressable Latch in My Logic Project

RSS Electro-Tech-Online.com Discussions

  • Measuring controller current output with a meter
  • KiCad custom symbol definition correct approach
  • restarting this Christmas project
  • Anyone In The US Ordered From AliExpress Recently?
  • My Advanced Realistic Humanoid Robots Project

Featured Tutorials

Real Time Hardware Filter Design

  • Practical implementation of bandpass and band reject filters
    Practical implementation of bandpass and band reject filters
  • Practical application of hardware filters with real-life examples
    Practical application of hardware filters with real-life examples
  • A filter design example
    A filter design example
  • Types of filter responses
    Types of filter responses
  • What are the two types of hardware filters?
    What are the two types of hardware filters?
  • What are hardware filters and their types?
    What are hardware filters and their types?
More Tutorials >

Recent Articles

  • Posifa sensors improve low-flow accuracy in compact systems
  • Acopian releases low-profile power supplies rated to 900 W
  • Octavo Systems OSDZU-3 REF Development Platform
  • Same Sky adds enclosure design to its audio engineering capabilities
  • Waterproof SMA-to-MHF I LK assemblies introduced by Amphenol RF

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
  • Guest Post Guidelines
  • Advertise
  • Subscribe