標(biāo)題: 單片機(jī)99倒計(jì)時(shí)到0仿真與源程序 [打印本頁(yè)]

作者: 電子發(fā)燒人    時(shí)間: 2017-12-30 19:41
標(biāo)題: 單片機(jī)99倒計(jì)時(shí)到0仿真與源程序
99到計(jì)時(shí)仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機(jī)源程序如下:
  1. #include<reg51.h>
  2. #include<intrins.h>
  3. #define uint unsigned int
  4. #define uchar unsigned char
  5. #define dat P0
  6. code uchar d[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
  7. uint second=99;
  8. uint sshi,sge;
  9. static char court=0;
  10.          
  11. void delay(uint number)              /*單個(gè)LED延時(shí)函數(shù)*/
  12. {uchar i,j;
  13.      for(i=0;i<number;i++)
  14.        for(j=0;j<200;j++);
  15.   }


  16. void int0() interrupt 1 using 2            /*中斷1為內(nèi)部中斷,0為外部中斷*/           /*中斷服務(wù)程序*/
  17. {
  18.   TH0=0x5c;
  19.   TL0=0xb0;
  20.   court++;         
  21. }

  22. void main()
  23. {
  24.             TMOD=0X01;
  25.             TH0=0x5c;
  26.             TL0=0xb0;
  27.             ET0=1;
  28. //            EX0=1;
  29. //            EX1=1;
  30. //            IT0=1;
  31. //            IT1=1;              /*開計(jì)數(shù)器中斷*/
  32.             EA=1;
  33.             TR0=1;          /*開定時(shí)器*/
  34.       while(1)                  /*中斷不能放循環(huán)中*/
  35.    {
  36.              sshi=second/10;
  37.               sge=second%10;
  38.              dat=d[sge];         /*第一個(gè)數(shù)碼管*/
  39.              P2=0x80;
  40.              delay(2);  
  41.              P2=0x00;
  42.              dat=d[sshi];
  43.              P2=0x40;
  44.              delay(2);
  45.              P2=0x00;  
  46.             
  47.                      
  48.         
  49.                    
  50. if(court==20)
  51.        {court=0;
  52.            second--;
  53.              if(second==0)
  54. ……………………

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

所有資料51hei提供下載:
99倒計(jì)時(shí)2.rar (59.14 KB, 下載次數(shù): 40)







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