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

📄 电子密码锁.lst

📁 肯定是你喜欢的东西了 自己打开看看了 就知道了
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.07   电子密码__                                                            11/09/2007 09:01:13 PAGE 1   


C51 COMPILER V7.07, COMPILATION OF MODULE 电子密码__
OBJECT MODULE PLACED IN 电子密码锁.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 电子密码锁.c OPTIMIZE(2,SPEED) DEFINE(monitor51) DEBUG OBJECTEXTEND

stmt level    source

   1          #include <reg51.h>
   2          #include <string.h>
   3          #include <intrins.h>
   4          #include <VIIC_C51.h>
   5          #define uchar   unsigned        char
   6          #define uint    unsigned        int
   7          #define KEY     P1
   8          #define DISP    P0
   9          #define null1   '\0'
  10          //**********************************
  11          sbit    LED=P2^0;         //密码正确点亮
  12          sbit    LED1=P2^1;        //密码错误点亮
  13          sbit    P14=P1^4;
  14          sbit    P15=P1^5;
  15          sbit    P16=P1^6;
  16          sbit    P17=P1^7;
  17          sbit    P22=P2^2;
  18          sbit    P23=P2^3;
  19          sbit    P24=P2^4;
  20          uchar   key;
  21          uchar   shuzi;
  22          uchar   statet;
  23          uchar   input_mima[9];
  24          uchar   mima[9]={0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F};
  25          uchar   k;
  26          uchar   kk;
  27          uchar   tab[13]={0x00,0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x39,0x5e};
  28          //***********************************
  29          void    delay(uint      i);
  30          void    delay_right(void);
  31          void    delay_wrong(void);
  32          void    init_main(void);
  33          void    main(void);
  34          void    get_key(void);
  35          void    change_mima(void);
  36          void    calc_disp(uchar array[9],uchar n);
  37          void    clear_arry(uchar *p,uchar n); //
  38          void    sendbyte(void);
  39          void    readbyte(void);
  40          //***********************************
  41          void    delay(uint      i)         //
  42          {
  43   1              while(--i);
  44   1      }
  45           //void delay1(double i)           //
  46          //{
  47          //      while(kk=0)
  48          //      {i--; if(kk=1) continue;   }
  49          //}
  50          //***********************************
  51          void    init_main(void)         // 初始化子程序
  52          {
  53   1              DISP=0;
  54   1              LED=0;
  55   1              LED1=0;
C51 COMPILER V7.07   电子密码__                                                            11/09/2007 09:01:13 PAGE 2   

  56   1      //      key_value=0;
  57   1          k=0;
  58   1          clear_arry(input_mima,9);
  59   1      //      clear_arry(mima,9);
  60   1      }
  61          //***********************************
  62          void sendbyte(void)
  63          {
  64   1        if((ISendStr(0x00,0x00,input_mima,8))!=1) statet=3;
  65   1      }
  66          //***********************************
  67          void readbyte(void)
  68          {
  69   1       if((IRcvStr(0x01,0x00,mima,8))!=1) statet=3;
  70   1          
  71   1      } 
  72          //***********************************
  73          void    main(void)
  74          {uchar lock=0; 
  75   1       init_main();
  76   1       statet=0;
  77   1       //readbyte();    
  78   1        while(1)
  79   1        {     
  80   2              get_key();
  81   2              //delay1(1200000);
  82   2              while(kk==1)
  83   2              {
  84   3                      kk=0;
  85   3                if (statet==0)
  86   3                  {
  87   4                  if(key!=0x00 && key!=0x39 && key!=0x5e)
  88   4              { 
  89   5                    input_mima[k]=key;
  90   5                        if(k<8) k++;
  91   5                        else
  92   5                        k=0;
  93   5                         }                      
  94   4                if(key==0x5e)
  95   4                  { 
  96   5                   if(strcmp(input_mima,mima)==0)
  97   5                    {statet=1;
  98   6                         delay_right();              
  99   6                     init_main();                
 100   6                    }
 101   5                  else 
 102   5                   {delay_wrong();
 103   6                        lock++;
 104   6                        if(lock<3)
 105   6                        statet=0;
 106   6                        else statet=2;
 107   6                    init_main();
 108   6                   }
 109   5                       }continue;
 110   4             }
 111   3                   
 112   3             if(statet==1)
 113   3                  { 
 114   4                        if(key==0x39)            
 115   4                    {
 116   5                         delay_right();
 117   5                         change_mima();
C51 COMPILER V7.07   电子密码__                                                            11/09/2007 09:01:13 PAGE 3   

 118   5                        }continue;
 119   4                       }
 120   3                       }calc_disp(input_mima,8);              
 121   2        }
 122   1      }
 123          //***********************************
 124          void   change_mima(void)
 125           { //uchar   xin_mima[9];
 126   1         uchar   new_mima[9];
 127   1         uchar   confirm_mima[9];
 128   1         uchar   xianshi[9];
 129   1         uint state1=0, state2=0, state3=0;
 130   1         uint l=0,m=0,n=0,i;
 131   1         for(i=0;i<=8;i++) xianshi[i]=null1;
 132   1         while(statet)
 133   1         { 
 134   2              get_key();
 135   2          while(kk==1)
 136   2               {kk=0;
 137   3                if (state1==0 && state2==0 && state3==0)
 138   3                {  if(key!=0x00 && key!=0x39 && key!=0x5e)
 139   4               {   input_mima[l]=key;
 140   5                           xianshi[l]=key;
 141   5                       if(l<8) l++;
 142   5                   }
 143   4              if(key==0x5e)
 144   4                     {delay_right();state1=1;for(i=0;i<=8;i++) xianshi[i]=null1;
 145   5                         }continue;
 146   4                }
 147   3                if (state1==1 && state2==0 && state3==0)
 148   3                {     
 149   4                  if(key!=0x00 && key!=0x39 && key!=0x5e)
 150   4               {   new_mima[m]=key;
 151   5                           xianshi[m]=key;
 152   5                               if(m<8) m++;
 153   5                   }
 154   4              if(key==0x5e)
 155   4                   { delay_right();state1=1; state2=1; for(i=0;i<=8;i++) xianshi[i]=null1; 
 156   5                       }continue;
 157   4                } 
 158   3                if (state1==1 && state2==1 && state3==0)
 159   3                {     
 160   4                  if(key!=0x00 && key!=0x39 && key!=0x5e)
 161   4               { confirm_mima[n]=key;
 162   5                         xianshi[n]=key;
 163   5                         if(n<8) n++;         
 164   5                   }
 165   4              if(key==0x5e)
 166   4                   { state1=1;state2=1;state3=1; }continue;
 167   4                }
 168   3                }
 169   2               
 170   2            while(state1==1 && state2==1 && state3==1)
 171   2                {
 172   3                  if(strcmp(input_mima,mima)==0 && strcmp(new_mima,confirm_mima)==0)
 173   3                        {for(i=0;i<8;i++)
 174   4                 input_mima[i]=new_mima[i];
 175   4                        // sendbyte();
 176   4                        // done1();
 177   4                         state1=1;state2=0;state3=1;statet=0;
 178   4                         delay_right();
 179   4                         }
C51 COMPILER V7.07   电子密码__                                                            11/09/2007 09:01:13 PAGE 4   

 180   3                      else { state1=1;state2=0;state3=1;statet=0;for(i=0;i<=9;i++) input_mima[i]=null1;delay_wrong();}
 181   3                      continue;
 182   3                }//continue;
 183   2               
 184   2                calc_disp(xianshi,8); 
 185   2       }
 186   1      }
 187          //***********************************
 188          void    delay_right(void)
 189          {       uchar m;
 190   1               for(m=10;m>0;m--)
 191   1              {
 192   2                      LED=1;
 193   2                      delay(2000);
 194   2                      delay(2000);
 195   2                      LED=0;
 196   2                      delay(2000);
 197   2                      delay(2000);
 198   2              }
 199   1      }
 200          //***********************************
 201          void    delay_wrong(void)
 202          {  uchar m;
 203   1              for(m=10;m>0;m--)
 204   1              {
 205   2                      LED1=1;
 206   2                      delay(2000);
 207   2              delay(2000);
 208   2                      LED1=0;
 209   2                      delay(2000);

⌨️ 快捷键说明

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