1、请支持原创,谢谢1、电路图2、程序:/*design by DX from GDOU*/#include #include #define uint8 unsigned charsbit led1=P10;sbit led2=P11;sbit led3=P12;sbit led4=P13;long int count1,count2; /存放上次的输入和现在的输入uint8 symbol,p; /存放符号的数值 p 用于多数输入清屏作用long int outputcount; /存放结果uint8 KeyCodeTable=0x28,0x14,0x24,0x44,0x12,0x22,0x42
2、,0x11,0x21,0x41,0x18,0x88,0x84,0x82,0x81,0x48; /键盘按键特征表 int table=0XC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X90 ;/不懂uint8 a4;void init()uint8 j;a0=0xc0;for(j=1;j=1000) i=x/1000;z0=i;aj=tablei;j+; if(x=100) i=(x-z0*1000)/100;z1=i;aj= tablei;j+; if(x=10) i=(x-z0*1000-z1*100)/10;z2=i;aj= tablei;j+;
3、 i=x%10;aj=tablei;void Calculate(uint8 key) /计算程序并显示 LEDuint8 i,j; static k=0;if(key10)if(p) p=0;for(j=0;j4;j+)aj=0xff; ak=tablekey;k=+k%4;count2*=10;count2+=key;outputcount=count2; /把当前按下的值先赋给 outputcountelse if(key=10) /清零键 k=0 ;init();else if(key15) k=0; p=1; switch(symbol) /多则运算时用于把之前的结果赋给 COUNT
4、1 case 0 :count1=count2 ;break;case 11:count1+=count2;break;case 12:count1-=count2;break;case 13:count1*=count2;break;case 14:count1/=count2;break;default: break;count2=0; /有符号输入时把之前的值赋给 count1,并把符号标号赋给 symbol;symbol=key; else switch(symbol)case 11:outputcount=count1+count2;break;case 12:outputcount
5、=count1-count2;break;case 13:outputcount=count1*count2;break;case 14:outputcount=count1/count2;break;default:break;for(j=0;j4;j+)aj=0xff; output(outputcount); void main()uint8 key;init();P0=0xff;led1=1;led2=1;led3=1;led4=1;while(1)display();if(key=keyscan()!=100) while(keyscan()!=100) ;Calculate(key);