Professional Documents
Culture Documents
Important
Important
int main(void)
{
unsigned char *number , operator1 , operator2 ;
int a ,b;
unsigned char *operand1[3] , operand2[6]={0} ;
int *operand;
operand = operand1;
char *result[2]={0};
int i = 0;
unsigned char colloc, rowloc;
KEY_DDR = 0xF0;
KEY_PRT = 0xFF;
usart_init(); //initialize serial communication
while(1)
{
do
{
KEY_PRT &= 0x0F;
asm("NOP");
colloc = (KEY_PIN & 0x0F);
} while(colloc != 0x0F);
do
{
do
{
_delay_ms(10);
colloc =(KEY_PIN&0x0F);
} while(colloc == 0x0F);
_delay_ms(10);
colloc = (KEY_PIN & 0x0F);
}while(colloc == 0x0F);
while(1)
{
KEY_PRT = 0xEF;
asm("NOP");
colloc = (KEY_PIN & 0x0F);
if(colloc != 0x0F)
{
rowloc = 0;
break;
}
KEY_PRT = 0xDF;
asm("NOP");
colloc = (KEY_PIN & 0x0F);
if(colloc != 0x0F)
{
rowloc = 1;
break;
}
KEY_PRT = 0xBF;
asm("NOP");
colloc = (KEY_PIN & 0x0F);
if(colloc != 0x0F)
{
rowloc = 2;
break;
}
KEY_PRT = 0x7F;
asm("NOP");
colloc = (KEY_PIN & 0x0F);
rowloc = 3;
break;
}
if(colloc == 0x0E){
number = (keypad[rowloc][0]); //transmit letter
}
else if(colloc == 0x0D) {
number = (keypad[rowloc][1] );}
if ( number!='=' )
{
operand1[i] = number;
i=i+1;
}
if ( number=='=')
{
i=0;
a = atoi(operand1);
a=a+2;
itoa (a,operand1,10);
usart_send(operand1[0]);
}
return 0;
}