标题: 单片机99倒计时到0仿真与源程序 [打印本页]

作者: 电子发烧人    时间: 2017-12-30 19:41
标题: 单片机99倒计时到0仿真与源程序
99到计时仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)


单片机源程序如下:
  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)              /*单个LED延时函数*/
  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为内部中断,0为外部中断*/           /*中断服务程序*/
  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;              /*开计数器中断*/
  32.             EA=1;
  33.             TR0=1;          /*开定时器*/
  34.       while(1)                  /*中断不能放循环中*/
  35.    {
  36.              sshi=second/10;
  37.               sge=second%10;
  38.              dat=d[sge];         /*第一个数码管*/
  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. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
99倒计时2.rar (59.14 KB, 下载次数: 40)







欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1