## Simple Calculator with CloudX Electronics

• ##### Project Details

This is a very simple calculator designed by Tumi Oyemade, posted on the makeelectronics.ng website.

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 to90000000. The calculator has the ability to detect math errors etc. Every kid, student and hobbyist should be able to do this fantastic project.

1x 16x2 LCD

Jumper Wires

## Circuit Connection

CloudX Connection pins with LCD

## GENERAL CIRCUIT DIAGRAM

## SOFTWARE CODE

You can copy code here and paste in your CloudX Software editor workspace

`/** File: Smart KeyPad Lock System.c * Author: hoodie * * Created on March 20, 2018, 11:21 AM */#include<CloudX/CloudX.h>#include<CloudX/Keypad.h>#include<CloudX/Lcd.h>#include <CloudX/stdlib.h>#define NumberOfRows 4 // set display to four rows#define NumberOfColumns 4 // set display to three columnschar KeypadCharacters[NumberOfRows][NumberOfColumns] = { '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 float answer;char * Panswer ;char Aanswer;signed long inputa;char Ainputa;signed long inputb;char Ainputb;setup(){    KeypadSetting (PULLDOWNCOL, RowPins, ColumnsPins, NumberOfRows, NumberOfColumns, KeypadCharacters);    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);    lcdCmd(cursor_blink);loop(){    Keys=getKey();    if(Keys!=0 && Keys=='C')    {     lcdCmd(lcd_clear);     lcdCmd(cursor_blink);    for(a=0; a<10; a++)    {      Ainputa[a]=0;     Ainputb[a]=0;     Aanswer[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 == '+')   {       answer = inputa + inputb;     longTostr(Aanswer , answer , DEC );   }    if(operation == '-')   {       answer = inputa - inputb;      longTostr(Aanswer , answer , DEC );   }    if(operation == '*')   {      answer = inputa * inputb;     longTostr(Aanswer , answer , DEC );   }   if(operation == '/')   {      answer = (float)inputa / (float)inputb;     Panswer = floatTostr(answer);  if(inputa > inputb)   {      Panswer=0;      } }  if(operation == '/')   {     lcdWriteText(2,1, "ANS: ");     lcdWriteTextCP( Panswer);   }  else    {       lcdWriteText(2,1, "ANS: ");     lcdWriteTextCP( Aanswer);   } }  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++;       }    }    }}`