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.
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 code
- int getKey () is taking inputs, digits from keypad.
- char getOper() is taking input , Operator from keypad.
- void result (float result) Displaying result on lcd.
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.
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.