標(biāo)題: 單片機(jī)按鍵控制數(shù)碼管加減數(shù)字演示仿真+程序 點(diǎn)不亮 [打印本頁]

作者: HTQQ123    時(shí)間: 2017-7-12 22:01
標(biāo)題: 單片機(jī)按鍵控制數(shù)碼管加減數(shù)字演示仿真+程序 點(diǎn)不亮
51單片機(jī)做的k1-k4按鍵控制數(shù)碼管加減演示仿真+程序

仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載):


單片機(jī)源程序如下:
  1. #include <reg52.h>
  2. #include <intrins.h>
  3. #define uchar unsigned char
  4. #define uint unsigned int

  5. uchar code DSY_CODE[]=
  6. {
  7.          0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff
  8. };
  9. uchar Num_Buffer[] = {0,0,0};
  10. uchar Key_Code,Key_Counts=0;

  11. void DelayMS(uint x)
  12. {
  13.          uchar t;
  14.         while(x--)
  15.         {
  16.                  for(t=0;t<120;t++);
  17.         }
  18. }

  19. void Show_Counts_ON_DSY()
  20. {
  21.          uchar i,j=0x01;
  22.         Num_Buffer[2]=Key_Counts/100;
  23.            Num_Buffer[1]=Key_Counts/10%10;
  24.         Num_Buffer[0]=Key_Counts%10;
  25.         for(i=0;i<3;i++)
  26.         {
  27.                  j = _cror_(j,1);
  28.                 P2 = j;
  29.                 P0 = DSY_CODE[Num_Buffer[i]];
  30.                 DelayMS(1);
  31.         }
  32. }

  33. void main()
  34. {
  35.          uchar i;
  36.         P0 = 0xff;
  37.         P1 = 0xff;
  38.         P2 = 0x00;
  39.         Key_Code = 0xff;
  40.         while(1)
  41.         {
  42.                  Show_Counts_ON_DSY();
  43.                 P1 = 0xff;
  44.                 Key_Code = P1;
  45.                 if(Key_Code != 0xff)
  46.                 {
  47.                         for(i=0;i<30;i++)
  48.                         {
  49.                                  Show_Counts_ON_DSY();
  50.                         }
  51.                 }
  52. ……………………

  53. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
K1-K4 控制數(shù)碼管加減演示.7z (22.72 KB, 下載次數(shù): 116)



作者: 110101    時(shí)間: 2019-6-16 17:41
那啥,樓主,我想說的是,你的proteus文件發(fā)錯了,你放了一個快捷方式proteusDNS,我們需要的是proteus project文件形式




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