## Introduction: Simple and Standard Calculator With CloudX

In this tutorial, we will be learning on how to make a simple and standard calculator with CloudX, Please click If you've not read anything on Interfacing keypad with CloudX before, Here, Our target is to teach you on how you can develop your own hardware calculator using cloudX M633.

Our aim is to be able to design a calculator that can do Addition (+), Subtraction (-), Multiplication (*) and Division (/)with Results in decimals as low as 0.0000001 and in whole numbers up to 90000000. The calculator has the ability to detect math errors etc. Every kid, student and hobbyist should be able to do this fantastic project.

## Step 2: PIN CONNECTION

CloudX Connection pins with LCD and CloudX Connection pins with Keypad

## Step 4: SOFTWARE

/*
* File: Smart KeyPad Lock System.c

* Author: hoodie

*

* Created on March 20, 2018, 11:21 AM

*/

#include<CloudX/CloudX.h>

#include<CloudX/Lcd.h>

#include<CloudX/stdlib.h>

#define NumberOfRows 4 // set display to four rows

#define NumberOfColumns 4 // set display to three columns

'1','2','3','+',

'4','5','6','-',

'7','8','9','*',

'C','0','=','/'

};

char RowPins[NumberOfRows] = {7, 8, 9, 10};

char ColumnsPins[NumberOfColumns] = {11, 12, 13, 14};

char Keys , a=0 , check =0 , operation=0 , signa=0 , signb=0;

signed long inputa;

char Ainputa;

signed long inputb;

char Ainputb;

setup(){

lcdSetting (1,2,3,4,5,6) ;

lcdCmd(lcd_clear);

lcdCmd(cursor_off);

lcdWriteText(1,1," CALCULATOR WITH");

lcdWriteText(2,1," CLOUDX ");

delayMs(2000);

lcdCmd(lcd_clear);

loop(){

Keys=getKey();

if(Keys!=0 && Keys=='C'){

lcdCmd(lcd_clear);

for(a=0; a<10; a++){

Ainputa[a]=0;

Ainputb[a]=0;

}

a=0;

operation=0;

check = 0;

signa =0;

signb =0;

}

if(check == 1 && Keys!=0 && Keys=='='){

lcdCmd(cursor_off);

inputa = atoi(Ainputa);

inputb = atoi(Ainputb);

if(signa=='-'){

inputa = -(inputa);

}

if(signb=='-'){

inputb = -(inputb);

}

if(operation == '+'){

}

if(operation == '-'){

}

if(operation == '*'){

}

if(operation == '/'){

if(inputa > inputb){

}

}

if(operation == '/'){

lcdWriteText(2,1, "ANS: ");

}

else {

lcdWriteText(2,1, "ANS: ");

}

}

if(Keys!=0 && (Keys=='+' || Keys=='-' || Keys=='*' || Keys=='/')){

if(operation != 0 && a==0 && signb ==0 && (Keys=='-'||Keys=='+')){

lcdWriteCP(Keys);

if(Keys=='-' || Keys=='+'){

signb = Keys;

}

}

if(operation == 0 && a == 0 && signa ==0 && (Keys=='-'||Keys=='+')){

lcdWriteCP(Keys);

if(Keys=='-' || Keys=='+'){

signa = Keys;

}

}

if(operation == 0 && a != 0){

lcdWriteCP(Keys);

operation = Keys;

a=0;

}

}

if (Keys!=0 && (Keys=='0'||Keys=='1'||Keys=='2'||Keys=='3'||Keys=='4'||Keys=='5'||Keys=='6'||Keys=='7'||Keys=='8'||Keys=='9')){

if(operation != 0){

lcdWriteCP(Keys);

Ainputb[a] = Keys;

a++;

check=1;

}

if(operation == 0){

lcdWriteCP(Keys);

Ainputa[a] = Keys;

a++;

}

}

}

}