74LS164级联控制5个数码管静态显示

74LS164级联控制5个数码管静态显示
仿真图:
74LS164级联控制5个数码管静态显示

74LS164级联控制5个数码管静态显示

源程序:

#include 
#include “MacroAndConst.h”
uint8 LEDBuffer[5]={0}; //显示缓冲区
//code uint8 tab[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x40};    //共阴极
code uint8 tab[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xbf}; //共阳极
sbit LED_DAT=P1^6;
sbit LED_CLKE=P1^5;
void bit_dat(bit i)                //向数码管写一个位
{
LED_CLKE=0;
LED_DAT=i;
LED_CLKE=1;
}
void uint_dat(uint8 i)                //向数码管写一个字母,8位
{
LED_CLKE=0;
bit_dat((bit)(tab[i]&0x80));
bit_dat((bit)(tab[i]&0x40));
bit_dat((bit)(tab[i]&0x20));
bit_dat((bit)(tab[i]&0x10));
bit_dat((bit)(tab[i]&0x08));
bit_dat((bit)(tab[i]&0x04));
bit_dat((bit)(tab[i]&0x02));
bit_dat((bit)(tab[i]&0x01));
LED_CLKE=0;
}
void uchar_dat()                //把缓存区的5个字符输入到5个数码管中
{
int j;
for(j=0;j<5;j  )
{
uint_dat(LEDBuffer[j]);
}
}
void main()
{
int i;
for(i=0;i<5;i  )
{
LEDBuffer[i]=i;
}
uchar_dat();
while(1);
}

 

版权声明:本文内容来源于网络搜集无法获知原创作者,仅供个人学习用途,若侵犯到您的权益请联系我们及时删除。邮箱:1370723259@qq.com

发表评论