Make a simple four function calculator with the Arduino MEGA.

## Step 1: Gather Your Materials

Arduino MEGA

some Dupont Cables

10kOhm linear potentiometer

12 push-buttons

LCD 16x2 display

12 10kOhm resistors

## Step 2: Connect Push-buttons

You want to connect the push buttons so that one side is connected to the left side of the breadboard and the other side of the push buttons is connected to the right side of the breadboard.

## Step 3: Connect LCD 16x2 Display to the Breadboard

You want to connect the LCD 16x2 display to the breadboard. I attached my LCD display on column C and started it on row 48 so that the last pin on the LCD display was on the last row (row 64)

## Step 4: Hooking the Breadboard Up to the Arduino MEGA

There are 10 buttons that are needed to represent the numbers 0-9 and there are two buttons that are to control the operations. The resistors are used to connect the buttons to ground and the Dupont cables are used to connect the buttons to VCC or power. Follow the pictures attached to set up the bread board and then use the Dupont cables to connect it to the Arduino MEGA. I made sure to keep all of the Dupont cables that are connecting to VCC in the same color so that I could easily make sure they were all in the same place.

Each push button has a corresponding number that it is plugged into on the Arduino MEGA. I will list those corresponding numbers below.

DEL --> 28

OK --> 29

0 --> 30

1 --> 31

2 --> 32

3 --> 33

4 --> 34

5 --> 35

6 --> 36

7 --> 37

8 --> 38

9 --> 39

## Step 5: Connecting the LCD Display to the Arduino MEGA

When connecting the LCD display to the Arduino MEGA, I had some issues off of the sketch that I was following. This took some tweaking on my part to make sure to get the LCD display connected. I am going to list the connections that I made in order to get it working. Some of these connections are to the Arduino MEGA and others are to the breadboard.

Starting on the left of the LCD display:

I connected the first pin with 46 ground on the breadboard.

The second pin with 47 power on the breadboard.

The third pin with i 50 on the breadboard. This is what connects the potentiometer to the LCD display.

The fourth pin got connected to 12 on the Arduino MEGA.

The fifth pin was connected to 55 ground on the breadboard.

The sixth pin was connected to 11 on the Arduino MEGA.

The seventh, eighth, ninth, and tenth pins did not have any connections or Dupont cables making connections.

The eleventh pin is connected to 5 on the Arduino MEGA.

The twelfth pin is connected to 4 on the Arduino MEGA.

The thirteenth pin is connected to 3 on the Arduino MEGA.

The fourteenth pin is connected to 2 on the Arduino MEGA.

The fifteenth pin is connected to power 50 on the breadboard.

The sixteenth pin is connected to ground 50 on the breadboard.

## Step 6: All Other Connections

There are a few other ground and power connections that need to be made. There is a connection from 51 ground to the ground on the Arduino MEGA. There is also a power connection from 51 power to 5V on the Arduino MEGA.

To make sure that the potentiometer is fully connected, there should be a connection between the left pin of the potentiometer and 48 ground. There is also a connection between the right pin of the potentiometer and 52 power.

## Step 7: The Final Step

This is what it will look like when you build on all of the connections. I broke them up into pieces so it was easier to see, but you should add on to each step with the next step. The last part that you have to use is the code. I did not write this code, but I acquired it from another instructable. This is the link to the instructable that I got the code from: https://www.instructables.com/id/Simple-calculator-...

There are three different zip files on this link, but the one that I used and the only one that worked for me was the one labeled raw_calculator.zip

## Step 8: How the Calculator Works

The first screen that pops up will ask about what function you want to complete. Each button, 0-3 has a certain function.

1 --> Subtraction

2 --> Multiplication

3 --> Division

After you select which function you want to do, the screen will say "FIRST NUMBER" and you can enter the number. After that you can either select another number to make a double, triple number etc. or you can hit the okay button. After hitting the okay button you can then select the second number. When you are done, hit okay to reveal your answer. The delete button is there to start over or if you need to delete a number or clear the function.

<p>This is a fun setup :) I'd have liked to make something like this in hs for math class.</p>