# Arduino Calculator Using 4×4 Keypad

Programming is amazing to work and Arduino is an amazing platform if you are a beginner at embedded programming. We have previously built a Boolean Algebraic Calculator using Arduino. In this article, we will learn to make our own mathematical calculator using Arduino. The values can be put in using a keypad (4×4 keypad) and the result will be shown on an LCD screen (16×2 dot-matrix display). This calculator could be used to do simple operations like addition, subtraction, multiplication and division with whole numbers. But once you have understood the concept, you can implement scientific functions parallelly with Arduino’s built-in functions.

When this project ends, you will learn to use a 16×2 LCD and keypad with Arduino and also know how easy it is to program using the already available Arduino IDE libraries. You will also get to know, how to program your Arduino to accomplish a specific task.

## Components Required

• Arduino Nano
• 16×2 LCD Display
• I2C LCD Module
• Connection Wires
• 5 Volt Power Supply

## Circuit Connection for Arduino Calculator

The complete circuit connection for this Arduino Calculator Project is shown above. The +5V and ground connection shown in the circuit diagram will be obtained from the 5V and ground pin of the Arduino. The Arduino will get its power from your laptop or through the DC jack which uses a 12V adapter or from a 9V battery.

We are running the LCD in a 4-bit system with Arduino so, only the last four data bits of the LCD are connected to Arduino. The keyboard has 8 output pins which we have to connect from pin 0 to pin 7 as mentioned in the diagram. You can also use the following connection table to recheck the connection with Arduino.

Some Arduino boards may show an error while uploading the program if there’s anything connected to pin 0 and pin 1, if you face any error just keep the keypad removed while uploading the program.

After your connections are done your hardware will be looking like this as mentioned shown below.

## PCB Design

After designing the schematic diagram of the Arduino Calculator System, the assembled components and wiring are too clumsy and looked very unprofessional. In fact, the wiring also has a chance of loose connection. To give it a clean and professional look and also to compress the size, I decided to build its PCB prototype using EasyEDA software as it is so simple to use. Now come to the main part, where we need to order our PCB prototype. I always prefer PCBWay for their quality assurance, fastest delivery and also for 24/7 customer support.

PCB View

Why I Choose PCBWay as My First Preference?

I’ve done several runs with PCBWay and am happy with the results, it’s good quality. The etching, solder mask, and hole sizes are all done well and that is what matters to me. It takes a few hours for a design to get approved and then a couple of days to finish and ship. With more than a decade in the field of PCB prototypes and fabrication, PCBWay has proved its assurance from time to time. They always look at the customer’s needs from different regions in terms of quality, on-time delivery, cost-effectiveness and any other demanding requests.

These PCBs were manufactured by PCBWay and the finish quality really impressive, especially with the gold finish path. If you want to finish your product faster you could also ask PCBWay to make a panelized order where you receive multiple PCBs in a single panel. Together with this, you will also receive SMT Stencil from PCBWay which will save you time and effort. All the orders are high quality and could select a lot of settings such as thickness, flexible PCB, the colour of the solder masks, the number of layers, material, surface finish and more.

## Working Principle of Arduino Calculator

Link the connections according to the circuit diagram and upload the code mentioned below. If it’s showing an error cross check that you have added the library according to the instructions given above. You can also run the simulation to check if your hardware has any problems. If everything is okay as it’s supposed to be, then your project will be looking like this below with the LCD displaying this, as the keypad that we used here doesn’t have any specific markings on it, I have assumed the alphabet to be operated.

You should mark what each button actually represents, it will be much easier to interpret, after that’s done, you can directly start using the calculator. Type the number and it will appear on the second line, press the operand and type your second number finally press the “#” key to get the result.

## Arduino Calculator Program

The complete Arduino program of this project is added at the end of this project. The code is divided into tiny meaningful pieces and is explained below.