[Updated 5/1]Building a simple calculator.

Hello all,

I just received my Arduino Uno today as a gift from one of my friends (Very excited)! I have always been interested in making a very simple calculator that could add, subtract, multiply, and divide numbers. Being a beginner, I have no idea where to start. I have thought of the components that I might need and I have already bought them.
1.The arduino uno, ofcourse.
2.LCD display
3.Keypad.
4.Jumper wires.
Now, if anyone could please guide me towards the right direction I would really appreciate it!!!!

Edit 5/1 : Using the useful comments I got from some of the users as well as reading some tutorials online and understanding more about the arduino, I think I am almost done with my very first project :). Only problem I am facing right now would be the coding. I downloaded a code from Don van der Drift's own tutorial on building a calculator. The code looks very messy and I think the code is split in two. If anyone could please take a look at the codes and tell me how I can embed them into my arduino I'd be very thankful.
Code source: arduino-code/calculator at master · donvanderdrift/arduino-code · GitHub

Welcome in Arduinoland,

my first advice is to go through the tutorial section (for several days) to get better understanding of how the programming language of Arduino works. (as I don't know your prog skills) .

A calculator needs to read a string (lets say from the serial monitor of the IDE) and parse that, Parsing is the splitting of a stream into meaningful parts. e.g. The stream
12 / 13 =
needs to be split in
Operand1 = 12
operator = divide
operand 2 = 13

Note the = sign can be used to start the parsing.

If you have those three parts you can (based upon the operand call the function
float divide(float a, float b)
{
if (b == 0) ... code to handle the error ;
return a / b;
}

which returns the result.

Hopes this gets you started.

Thank you for taking the time to read through my post and reply. However, programming is not where I am stuck. I am afraid it is more of how to connect everything together. Is there anyway you could know what should go where ? Also, am I missing any components?

In the tutorial section there is a lot of info you are searching for,
also in the playground section there is plenty of info how to connect.

Hi insanehadi,

You will need some breadboards, LEDs, pushbutton switches, resistors, capacitors and an inexpensive digital multimeter. You may not require all of these as part of your calculator, but they will be invaluable as you learn about Arduino and build simple circuuts and prototype your calculator.

EDIT: you will also need a trimmer-potentiometer to adjust the contrast on the LCD.

Paul

Thanks Paul that was helpful :slight_smile:

Edit: Any deeper help is still greatly needed! Help such as the values of the resistors the capacitors and why do I need them.

Resistors:

A few of around 220R or 330R range for use as series resistors with LEDs. These limit the current so the LED and the Arduino outputs are not damaged. A few of 10K for use as pull-up or pull-down purposes for switch inputs. These prevent Arduino inputs "floating" and giving random readings (although you can often use the Arduino's internal pull-ups). While shopping, get a few other values like 1K, 4K7.

Capacitors:

You may not need many at first, but if shopping, get some 0.1uF for use as "isolation" and noise suppression circuits and some "electrolytic" ones in the 10uF to 470uF range for use as "local power reservoirs".

Potentiometer:

10K linear will be fine.

Breadboards:

I like the relatively small ones with ~300 connectors. Get a few and you can clip them together into a shape that suits your project. Some of these come with "power strips" built-in and with some you buy those separately. You don't have to have power rails on every breadboard as long as they all clip together.

I would also get an LCD like this one: Serial Enabled 16x2 LCD - Yellow on Blue 5V - LCD-09396 - SparkFun Electronics
What you are looking for is a serial interface for the LCD. This will simplify your life greatly when dealing with programming the LCD, rather than digging up libraries for it, since you just output to a serial port (Which is already setup in the arduino).

Otherwise, I'd recommend digging around and finding the parts you think you need and can afford, and then if you have questions, link the part here and we will probably be able to answer you if it is specific enough.

Could not find this anywhere around the electronic shops here, so I just used the normal LCD.

the code is not split
*.h file define functions and include what you need
*.cpp is the program in c++ that you can do using *.h ressources