• 573锁存器驱动8段数码管


    #include <reg51.h>
     
     #define SEG  P2 
     sbit P1_0 = P1^0;
     
     sbit P1_1 = P1^1;
     sbit P1_2 = P1^2;
     sbit P1_3 = P1^3;
     sbit P1_4 = P1^4;
     
     unsigned char code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x3c,0x07,0x7f,0x37}; //共阴极
     void delay(int x);
     
    
    void main()
    {
         while(1)   //2015 
         {
         
         P1_0 =0; //573 低电平使能
        SEG =tab[2]; //送段位
        P1_1 = 0;    //点亮数码管
             
      P1_0 = 1;    //关闭锁存
        P1_1 = 1;    //关闭数码管
    
            
            
        P1_0 =0; //573 低电平使能
        SEG =tab[0];
        P1_2 = 0;
             
      P1_0 = 1;
        P1_2 = 1;
    
         
            
            
            
        P1_0 =0; //573 低电平使能
        SEG =tab[1];
        P1_3 = 0;
             
        P1_0 = 1;
        P1_3 = 1;
        
        
        P1_0 =0; //573 低电平使能
        SEG =tab[5];
        P1_4 = 0;
             
        P1_0 = 1;
        P1_4 = 1;
         
        
        
         
         
        
    }
         
    }
    
    void delay(int x)  //6ms*x    23MHZ晶振
    {
        int i,j;
        for( i=0;i<x;i++)
        for( j =0;j<12000;j++);
    }
    #include <reg51.h>
     
     #define SEG  P2 
     sbit P1_0 = P1^0;
     
     sbit P1_1 = P1^1;
     sbit P1_2 = P1^2;
     sbit P1_3 = P1^3;
     sbit P1_4 = P1^4;
     
     unsigned char code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x3c,0x07,0x7f,0x37};
     void delay(int x);
     
    
    void main()
    {
         while(1)   //521 1314
         {
        P1_0 =0; //573 低电平使能
        SEG =tab[5]; //送段位
        P1_1 = 0;    //点亮数码管
            delay(166);   //延时
      P1_0 = 1;    //关闭锁存
        P1_1 = 1;    //关闭数码管
    
            
            
            P1_0 =0; //573 低电平使能
        SEG =tab[2];
        P1_2 = 0;
        delay(166);
      P1_0 = 1;
        P1_2 = 1;
    
         
            
            
            
        P1_0 =0; //573 低电平使能
        SEG =tab[1];
        P1_3 = 0;
        delay(166);
        P1_0 = 1;
        P1_3 = 1;
     
         
    
    ////////////////////////////////////////////   1314
        
        P1_0 =0; //573 低电平使能
        SEG =tab[1]; //送段位
        P1_1 = 0;    //点亮数码管
            delay(166);   //延时
      P1_0 = 1;    //关闭锁存
        P1_1 = 1;    //关闭数码管
    
            
            
        P1_0 =0; //573 低电平使能
        SEG =tab[3];
        P1_2 = 0;
        delay(166);
      P1_0 = 1;
        P1_2 = 1;
    
         
            
            
            
        P1_0 =0; //573 低电平使能
        SEG =tab[1];
        P1_3 = 0;
        delay(166);
        P1_0 = 1;
        P1_3 = 1;
        
        
        P1_0 =0; //573 低电平使能
        SEG =tab[4];
        P1_4 = 0;
        delay(166);
        P1_0 = 1;
        P1_4 = 1;
        
        
         
        
        
    }
         
    }
    
    void delay(int x)  //6ms*x    23MHZ晶振
    {
        int i,j;
        for( i=0;i<x;i++)
        for( j =0;j<12000;j++);
    }

  • 相关阅读:
    11.个别程序题
    常见设计模式部分
    框架部分综合
    mybatis部分
    spring部分
    hibernate部分
    struts2部分
    10.java反射和类加载机制
    9.垃圾回收机制和JVM
    oracle部分
  • 原文地址:https://www.cnblogs.com/zhaocundang/p/4954097.html
Copyright © 2020-2023  润新知