Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

calculator program bt using micro controller

Status
Not open for further replies.

suga

Member level 2
Joined
Jan 23, 2012
Messages
49
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
chennai
Activity points
1,596
Hi
calculator program by using micro controller.In that I need some ideas.I wrote upto press a keys in keypad means number will display on lcd.futher I have to write a coding for calculator plz help for that.
 

I assume you want a basic calculator. That means * , / , - , +
Those are basic operations that do not need any fancy algorithms and can be implemented as such. Simply store the user input (numbers as well as operations) and do the calculations and display the result.

This should be simple enough. Try it out and post more questions IF you get stuck somewhere.
 
how to store the user input?? and this is pgm
Code:
#include<reg51.h>
#define p0 P0
#define p2 P2  
unsigned int i,m0,m1,v1;  
sbit c1=P2^4;
sbit c2=P2^5;
sbit c3=P2^6;
sbit c4=P2^7;
sbit r1=P2^0;
sbit r2=P2^1;
sbit r3=P2^2;
sbit r4=P2^3;

sfr a=0x90;
sbit rs=P3^7;
sbit rw=P3^6;
sbit en=P3^5;
void lcd();
void keypad();
int add(int m1,int m2); 
void lcd_d( char val);
void lcd_in( char val);



void wait(int j)
{
long int i;
for(i=0;i<j;i++);
}
void main()
{
int m1,m2;
p2=0x0f;
lcd();
while(1)
{
keypad();
}
void keypad()
{
 
if( c3=0,c2=c1=c4=1,r1==0)
{
p0=0x20;
lcd_d('/');
}
if (c4=0,c2=c3=c1=1,r1==0)
{
p0=0x30;
lcd_d('*');
}

if(c1=0,c2=c3=c4=1,r2==0)
{
p0=0x40;
lcd_d('-');
}
if( c2=0,c1=c3=c4=1,r2==0)
{
p0=0x50;
lcd_d('+');
}
if( c3=0,c2=c1=c4=1,r2==0)
{
p0=0x60;
lcd_d('9');
}
if (c4=0,c2=c3=c1=1,r2==0)
{
p0=0x70;
lcd_d('8');
}

if(c1=0,c2=c3=c4=1,r3==0)
{
p0=0x80;
lcd_d('7');
}
if( c2=0,c1=c3=c4=1,r3==0)
{
p0=0x90;
lcd_d('6');
}
if( c3=0,c2=c1=c4=1,r3==0)
{
p0=0xa0;
lcd_d('5');
}
if (c4=0,c2=c3=c1=1,r3==0)
{
p0=0xb0;

lcd_d('4');
}

if(c1=0,c2=c3=c4=1,r4==0)
{
p0=0xc0;

lcd_d('3');
}
if( c2=0,c1=c3=c4=1,r4==0)
{
p0=0xd0;
lcd_d('2');
v1=v1+2;

}
if( c3=0,c2=c1=c4=1,r4==0)
{
p0=0xe0;

lcd_d('1');
}
if (c4=0,c2=c3=c1=1,r4==0)
{
p0=0xf0;

lcd_d('0');
}
}
 

man,have you ever used a uC ? just pick up a dev kit and give it a shot ! Things might sound scary if you're a noob and I put them down into text

But if you follow a simple tutorial on your dev kit,you'll realise that it's so very easy.

And since you asked :-

< badly formatted pseudocode >
int a = {user input number 1}
int b = {user input number 2}


float c=0 ;

if(multiply)
{ c= a*b; }

if(divide)
{ c=a/b; }

.......< and so on > .....
.....finally....

function_display(c);
 

I have to display on LCD.here am using 4x4 keypad.
 

i have to display on 16x2 LCD with 4x4 keypad but by using MCU 8051 ide software...i don't have any idea how to do it..can someone help
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top