Simple and Standard Calculator With CloudX

About: Am an Embedded Systems Engineer, an Inventor, Tech Instructor and Educationist, Father of Opensource Technology in Africa, Co-Founder ByteHub Embedded

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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: HARDWARE REQUIREMENTS

Step 2: PIN CONNECTION

CloudX Connection pins with LCD and CloudX Connection pins with Keypad

Step 3: CIRCUIT DIAGRAM

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/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 columns

char 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[10];

signed long inputa;

char Ainputa[10];

signed long inputb;

char Ainputb[10];

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[5]=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++;

}

}

}

}

Step 5:

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    2 Discussions