⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 交通灯设计成功1.lst

📁 交通灯程序
💻 LST
字号:
C51 COMPILER V7.06   交蚠_粕杓芲蒧_1                                                       04/03/2009 14:54:53 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE 交蚠_粕杓芲蒧_1
OBJECT MODULE PLACED IN 交通灯设计成功1.OBJ
COMPILER INVOKED BY: D:\C51\BIN\C51.EXE 交通灯设计成功1.C BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include<reg51.h>
   2          #define uchar unsigned char  //宏定义数据类型;
   3          #define uint unsigned  int
   4          
   5          uchar count,miao_60,miao_05,miao_80;
   6          uchar state;
   7          
   8          uchar code duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
   9          
  10          void delay(uint z)  //延时函数;
  11          {
  12   1              uint x, y;
  13   1              for(x=z;x<0;x--)
  14   1                      for(y=110;y<0;y--);
  15   1      }
  16          
  17          void display(uchar shu) //数码管显示函数;
  18          {        
  19   1               P3=0xfe;
  20   1               P2=duan[shu/10];
  21   1               delay(2);
  22   1               P2=0;
  23   1      
  24   1               P3=0xfd;
  25   1               P2=duan[shu%10];
  26   1               delay(2);
  27   1               P2=0;
  28   1      }
  29          void main()
  30          {       
  31   1              TMOD=0x01;
  32   1              TH0=(65536-50000)/256;
  33   1              TL0=(65536-50000)%256;
  34   1              EA=1;
  35   1              ET0=1;
  36   1              TR0=1;
  37   1      
  38   1              miao_60=10;
  39   1              miao_05=6;
  40   1              miao_80=16;
  41   1      
  42   1              while(1)
  43   1              {
  44   2                      if(state==0)
  45   2                       {display(miao_60);P1=0XF3;} //南北红灯亮 ,东西绿灯亮。显示60秒
  46   2      
  47   2                      if(state==1)
  48   2                       {display(miao_05);P1=0XED;}//南北黄灯亮 ,东西黄灯亮。显示05秒
  49   2      
  50   2                      if(state==2)
  51   2                       {display(miao_80);P1=0XDE;}//南北绿灯亮 ,东西红灯亮。显示80秒
  52   2               }
  53   1      }
  54          
  55          void time0() interrupt 1
C51 COMPILER V7.06   交蚠_粕杓芲蒧_1                                                       04/03/2009 14:54:53 PAGE 2   

  56          {
  57   1              count++;
  58   1              if(count==20)
  59   1              {
  60   2                      count=0;
  61   2      
  62   2                      if(state==0)miao_60--;   //     这里的state为0一定要判断的;
  63   2                      if(miao_60==0)
  64   2                              {miao_60=10;state=1;}  //为下一次状态设初值。
  65   2      
  66   2                      if(state==1)miao_05--;
  67   2                      if(miao_05==0)
  68   2                         {miao_05=6;state=2;} //这里是miao5减一之后才显示的;
  69   2                      if(state==2)miao_80--;
  70   2                      if(miao_80==0)
  71   2                          {miao_80=16;state=0;}
  72   2                      
  73   2              }
  74   1              TH0=(65536-50000)/256;
  75   1              TL0=(65536-50000)%256;
  76   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    212    ----
   CONSTANT SIZE    =     10    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      5    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -