码迷,mamicode.com
首页 > 其他好文 > 详细

573锁存器驱动8段数码管

时间:2015-11-10 21:13:15      阅读:299      评论:0      收藏:0      [点我收藏+]

标签:

#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++);
}

 

 

技术分享

573锁存器驱动8段数码管

标签:

原文地址:http://www.cnblogs.com/xiaobo-Linux/p/4954097.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!