欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: 單片機(jī)計(jì)算器Proteus仿真程序 兩位數(shù)以內(nèi)加減法 [打印本頁]

作者: kgs19951018    時(shí)間: 2019-11-18 18:54
標(biāo)題: 單片機(jī)計(jì)算器Proteus仿真程序 兩位數(shù)以內(nèi)加減法
兩位數(shù)以內(nèi)加減法,比較適合初學(xué)者
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機(jī)源程序如下:
  1. #include<reg51.h>
  2. unsigned int k=0,k1,k2,k3,k4,z=0;
  3. unsigned char code tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
  4. void delay(unsigned char x)
  5. {
  6.   unsigned char y;
  7.   for(;x>0;x--)
  8.   for(y=110;y>0;y--);
  9. }
  10. unsigned char key()
  11. {
  12. unsigned char row,col,m=0xff;
  13. P2=0xf0;
  14. if(P2==0xf0)
  15.   return m;
  16. delay(20);
  17. if(P2==0xff)
  18.   return m;
  19. for(row=0;row<4;row++)
  20.   {
  21.    P2=~(1<<row);
  22.    if((P2&0xf0)!=0xf0)
  23.     break;
  24.   }
  25. for(col=0;col<4;col++)
  26.   {
  27.    P2=~(1<<(col+4));
  28.    if((P2&0x0f)!=0x0f)
  29.     break;
  30.   }
  31.   if(row<4&&col<4)
  32.    m=row*4+col;
  33.   P2=0xf0;
  34.   while((P2&0xf0)!=0xf0);
  35.   z++;
  36.   return m;
  37. }
  38. void display(unsigned char a)
  39. {
  40. unsigned shi,ge;
  41. shi=a/10;
  42. ge=a%10;
  43. if(shi==0)
  44.         P0=0xff;
  45. else
  46.         P0=tab[shi];
  47. P1=0x01;
  48. delay(5);
  49. P0=0xff;
  50. P0=tab[ge];
  51. P1=0x02;
  52. delay(5);
  53. P0=0xff;
  54. }
  55. void main()
  56. {
  57. while(1)
  58. {
  59.   k=key();
  60.   if(k>=0&&k<=9&&z==1&&k!=0xff)
  61.    {
  62.     k1=k;
  63.         k3=k1;
  64.    }
  65.    delay(20);
  66.   if(k>=0&&k<=9&&z==2&&k!=0xff)
  67.    {
  68.         k2=k;
  69.         k1=k3*10+k2;
  70.    }
  71.   if(k==10)
  72.    {
  73.         k4=k1;
  74.            z=0;
  75.    }
  76.   if(k==11)
  77.    {
  78.            k1=k1+k4;
  79.    }
  80.    display(k1);
  81.    }
  82. }
復(fù)制代碼

所有資料51hei提供下載:
兩位數(shù)以內(nèi)加減法.zip (17.58 KB, 下載次數(shù): 55)



作者: moluxiyan    時(shí)間: 2019-11-20 17:16
感謝分享,很詳細(xì)
作者: 小小蛋    時(shí)間: 2019-11-27 09:03
很好,正是我需要的。

作者: 7066799sq    時(shí)間: 2020-5-15 14:57
這個(gè)是四位共陽極數(shù)碼管和矩陣鍵盤實(shí)現(xiàn)的兩位數(shù)加減法嗎?
作者: 卡卡魯斯    時(shí)間: 2022-9-15 11:49
不懂就問,減在哪里




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1