Arduino Calculator Circuit

In this particular write-up, we intend to build a scientific Arduino calculator circuit, that may carry out significantly intricate arithmetical calculation in comparison with a regular calculator.

The idea about this article is just not to have a calculator using Arduino, but for highlighting the arithmetical capacity of Arduino, which executes numerous elaborate data interpretations and computations through the sensors along with other peripherals.

In this enjoyable project you simply need a USB cable and Arduino of your choice. We intend to obtain the outcome of our calculations through serial monitor of Arduino IDE. In case you are knowledgeable about fundamentals of C language this particular assignment can be a easy, and you may develop your own applications which will do a lot more complicated arithmetical calculations. In this article we intend to make use of a header file #include which is integrated in the Arduino IDE compiler, therefore you would not require to download virtually any library.

You can actually hook up a LCD display and keyboard with Arduino and create a scientific calculator, however it is matter of a different post. Should you be acquainted with “Turbo C++” one of our 1st courses is going to be addition of a couple of figures, each of the arithmetical computations tend to be brought inside the CPU of the computer. However in this article, each of the arithmetical calculations are performed within the Arduino microcontroller. Let us begin with addition, subtraction, division and multiplication.

Listed here is a program using a couple of variable a and b, applying both of these factors you can accomplish the above mentioned data utilizing “ +, -, * / ” operators, which might be addition, subtraction, multiplication, division correspondingly.

Program:

#include<math.h>

float a = 500;

float b = 105.33;

float add;

float sub;

float divide;

float mul;

void setup()

{

Serial.begin(9600);

Serial.println(“Simple Arduino Calculator:”);

Serial.println(“\n”);

Serial.print(“a = “);

Serial.println(a);

Serial.print(“b = “);

Serial.println(b);

Serial.println(“\n”);

Serial.print(“Addition: “);

Serial.print(“a + b = “); // add

add=a+b;

Serial.println(add);

Serial.print(“Multiplication: “);

Serial.print(“a * b = “); // multiply

mul=a*b;

Serial.println(mul);

Serial.print(“Division: “);

Serial.print(“a / b = “); // divide

divide=a/b;

Serial.println(divide);

Serial.print(“Subtraction: “);

Serial.print(“a – b = “); // subtract

sub=a-b;

Serial.println(sub);

}

void loop() // we need this to be here even though its empty

{

}

OUTPUT:

Throughout these program we have been making use of “Float” that works decimal functions, we have been applying “Serial.print();” for publishing the principles in serial monitor, remaining program is self instructive. You are able to alter the variable a and b in the system with your personal principles.

Let us transfer something better, such as area of circle. The formulation for area of circle is: pi * radius^2 or pi times radius square. Considering that the value of pi will be constant, we must designate it within the program implementing “float” because the value of pi is 3.14159 wheresoever decimal point involves.

Program:

//——————-Program Developed by R.Girish—————//

#include<math.h>

float pi = 3.14159;

float radius = 50;

float area;

void setup()

{

Serial.begin(9600);

Serial.println(“Arduino Area Calculator:”);

Serial.print(“\n”);

Serial.print(“Radius = “);

Serial.print(radius);

Serial.print(“\n”);

area = pi*sq(radius);

Serial.print(“The Area of circle is: “);

Serial.println(area);

}

void loop()

{

// we need this to be here even though it is empty

}

//——————-Program Developed by R.Girish—————//

OUTPUT:

Yet again, you are able to replace the principles of your personal choice in the program. We have been making use of “sq()” that executes squaring of the number within the parenthesis. At this point let us proceed to the subsequent stage. Within this program we intend to make use of Pythagoras theorem in order to calculate the hypotenuse of a triangle. The method behind this is: “hyp=sqrt(sq(base) + sq(height)); “ or square root of (base square + height square).
Program:

//——————-Program Developed by R.Girish—————//

#include<math.h>

float base = 50.36;

float height = 45.336;

float hyp;

void setup()

{

Serial.begin(9600);

Serial.println(“Arduino Pythagoras Calculator:”);

Serial.print(“\n”);

Serial.print(“base = “);

Serial.println(base);

Serial.print(“height = “);

Serial.print(height);

Serial.print(“\n”);

hyp=sqrt(sq(base) + sq(height));

Serial.print(“The hypotenuse is: “);

Serial.print(hyp);

}

void loop()

{

// we need this to be here even though its empty

}

//——————-Program Developed by R.Girish—————//

OUTPUT:

It is possible to replace the values of base and height with your personal principles in the program. We applied “sqrt()” which usually can square root function values inside the parenthesis. Now let us execute a well-liked program which usually we might have studied in our outset of C language training course, Fibonacci series.

The bottom line is the Fibonacci series is actually addition of 2 prior numbers which provides subsequent number and so forth, it often commences with 0, 1. For instance: 0, 1. So 0+1=1; next series is 0, 1, 1. Therefore, 1+1=2. Consequently next series is, 0, 1, 1, 2…..and so forth. This system created here is to obtain the Fibonacci number for 1st nth digit. You are able to replace the value of ‘n’ in the system to achieve the preferred Fibonacci series.

Program:

//——————-Program Developed by R.Girish—————//

#include<math.h>

int n=6;

int first = 0;

int Second = 1;

int next;

int c;

void setup()

{

Serial.begin(9600);

Serial.print(“Fibonacci series for first “);

Serial.print(n);

Serial.print(” numbers are:\n\n”);

for ( c = 0 ; c < n ; c++ )

{

if ( c <= 1 )

next = c;

else

{

next = first + Second;

first = Second;

Second = next;

}

Serial.println(next);

}

}

void loop()

{

// put your main code here, to run repeatedly:

}

//——————-Program Developed by R.Girish—————//

OUTPUT:

Therefore, this may have offered adequate amounts for your head and baffled that anything made to control hardware peripherals has been performing several non-sense math computation, in that case, you aren’t the only one.

The math performs an important function in electronics honestly, that is precisely why our textbook abounds with mathematical equations, that people do not even fully grasp and that’s where calculators come to save us and here it really is.

Should you have any concerns relating to this Arduino calculator circuit, you may convey them by means of your ever valuable feedback.