DIY Arduino Calculator Using OLED Display

by MissionCritical in Circuits > Arduino

4896 Views, 4 Favorites, 0 Comments

DIY Arduino Calculator Using OLED Display

thmnl.jpg

in one of my previous Instructable tutorial, we learnt how to interface an OLED with Arduino and basics of it, now its time to step up the game and make some project based on OLED, so in this tutorial, we will learn how to make a simple yet slinky calculator based on Arduino!

Supplies

Watch the Video!

Choice of Material!

2.jpg
3.jpg
1.jpg
vlcsnap-00041.jpg
vlcsnap-00040.jpg

to make a calculator, we will need some kind of Processor, for which we can use Arduino, since this is a small project and needs large memory space for complicated code, we will use Arduino NANO.

for taking input number, we can use a 4x4 keypad with membrane switches, which has 4 rows and 4 columns, if we open up this sticker from behind, the flexible membrane PCB is visible, which has connections going from ROWS and COLUMNS to connecting pins via flexible PCB. When any membrane switch is pressed, the rows and column pins process the data as a Matrix and identify the location of key pressed.(Remember, left side pins are row pins and right side pins are column pins.)

for display we can use either OLED or LCD display, but I would like to use OLED, since the resolution of OLED is far better, we can have longer strings of numbers to operate, if we choose OLED.

Complete the Connections

vlcsnap-00043.jpg
vlcsnap-00044.jpg
vlcsnap-00042.jpg
vlcsnap-00046.jpg
vlcsnap-00047.jpg
vlcsnap-00049.jpg
ckt-png.png

since we discussed the choice of material, connections should be very straight forward, so follow the following steps to complete the connections:

  1. connect Keypad to any digital pins on Arduino Nano ( preferably D2 to D9).
  2. connect OLEDs SCL to Arduinos A5.
  3. connect OLEDs SDA to Arduinos A4.

  4. connect OLEDs VCC to Arduinos 5v.

  5. connect OLEDs GND to Arduinos GND.

  6. Connect a Switch between Positive of Lithium Polymer Battery.

  7. Connect Lipo to 5V and Gnd pins of Arduino.

and that all for connections!

Upload the Code

5.jpg
4.jpg
6.jpg
7.jpg

in this code, we will need the following Libraries.

Steps:

  1. First we included Keypad library,
  2. next we will add SPI wire,Adafruit GFX and Adafruit SSD1306 libraries for OLED.
  3. Then we will initialize the OLED.
  4. Define Rows and Columns,
  5. Define Variables.
  6. Map out the Keypad in form of matrix, where in our A key is replaced by + operator, B with minus, c with multiplier, D with Divisor, hash with equals and finally star with clear.
  7. in byte rowPins and colPins we define the pin out of keypad and initialize the Keypad,
  8. next we have a startup animation Screen set up in this sub-code.
  9. In the loop section, we will use cases for each operator and do the calculation keeping in mind the operators.

you can download the code here!

<br> some error in code, fixed and attached above

Test the Project

vlcsnap-00001.jpg
vlcsnap-00002.jpg
vlcsnap-00004.jpg

Once this code is uploaded to Arduino, we can see a startup animation screen saying Arduino Calculator by Mission Critical, followed by blank screen, which we will use for operations, So we can now add numbers, subtract act them, multiply them, divide them, we can also use obtained answer and perform operations on it!

Create an Enclosure

8.jpg
vlcsnap-00006.jpg
10.jpg
9.jpg
vlcsnap-00010.jpg

But let’s leave this project hanging and make a simple enclosure for it. I had this small box with me, which I used as base for this enclosure. I want this project to be portable, so I used a Lithium Ion Battery to power Arduino, which I soldered along with a little switch to Arduino’s 5v pin and ground pin, and stuffed everything inside, finally used a little hot glue to place OLED and Keypad at required location.

Thank You!

12.jpg
11.jpg

After this coding and wiring mess, the end result looks absolutely charming and of course functional.

So I hope you guys enjoyed this simple Arduino project tutorial, and I hope you guys learnt something from this tutorial, and if you liked it, make sure to check out our other work on youtube, you can also support us for following Mission Critical on social media or becoming our patreon.

Patreon - https://www.patreon.com/missioncritical
Twitter @ akshaymomaya1 Instagram @officialmissioncritical Facebook https://www.facebook.com/officialmissioncritical/