基于74hc573的数码管模块测试

今天测试了一下刚刚到手的数码管模块

在这里插入图片描述
测试正常

测试源码如下:

#include <reg52.h>
sbit wei=P1^0;//L2
sbit duan=P1^1;//L1

void Delay_ms(unsigned int n)
{
	unsigned int i,j;
	for(i=n;i>0;i--)
		for(j=114;j>0;j--);
}

unsigned char tab[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
unsigned char weitab[]={0x10,0x20,0x40,0x80,0x01,0x02,0x04,0x08};
unsigned char smgtab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x80,0xff,0x00,0x40};	  //0~9  .  全亮  全灭    -:0x40

int hour=23,min=59,sec=55,time_1s=0,inter=0;
void time0() interrupt 1
{
	TH0=(65536-2000)/256;
	TL0=(65536-2000)%256;
	inter++;   
	if(inter == 500)  	//1s执行一次
	{
	    inter = 0;
		time_1s++;
		if(time_1s==2)
			time_1s=0;
		sec++;
		if(sec >= 60)
		{
			sec = 0;
			min++;
			if(min >= 60)
			{
				min = 0;
				hour++;
				if(hour >= 24)
				{
					hour = 0;
				}
			}
		}
	}					  
}

void Init_TIME0(void)
{
	TMOD |=	0x01;
	TH0=(65536-2000)/256;
	TL0=(65536-2000)%256;
	EA=1;
	ET0=1;
	TR0=1;
}


int main(void)
{
	int i=0,j=0;
	Init_TIME0();
	while(1)
	{
		P2=smgtab[12]; 
		duan=1;
	   	duan=0;			

		P2=~weitab[0]; 
		wei=1;
		wei=0;
		
	   	P2=smgtab[hour/10]; 
		duan=1;
	   	duan=0;
		Delay_ms(1);

		P2=smgtab[12]; 
		duan=1;
	   	duan=0;

		P2=~weitab[1]; 
		wei=1;
		wei=0;

	   	P2=smgtab[hour%10]; 
		duan=1;
	   	duan=0;
		Delay_ms(1);
	   	
		P2=smgtab[12]; 
		duan=1;
	   	duan=0;

		P2=~weitab[2]; 
		wei=1;
		wei=0;

	   	P2=smgtab[13]; 
		duan=1;
	   	duan=0;
		Delay_ms(1);

		P2=smgtab[12]; 
		duan=1;
	   	duan=0;

		P2=~weitab[3]; 
		wei=1;
		wei=0;
		
	   	P2=smgtab[min/10]; 
		duan=1;
	   	duan=0;
		Delay_ms(1);

		P2=smgtab[12]; 
		duan=1;
	   	duan=0;

		P2=~weitab[4]; 
		wei=1;
		wei=0;

	   	P2=smgtab[min%10]; 
		duan=1;
	   	duan=0;
		Delay_ms(1);

		P2=smgtab[12]; 
		duan=1;
	   	duan=0;

		P2=~weitab[5]; 
		wei=1;
		wei=0;

	   	P2=smgtab[13]; 
		duan=1;
	   	duan=0;
		Delay_ms(1);

		P2=smgtab[12]; 
		duan=1;
	   	duan=0;

		P2=~weitab[6]; 
		wei=1;
		wei=0;
		
	   	P2=smgtab[sec/10]; 
		duan=1;
	   	duan=0;
		Delay_ms(1);

		P2=smgtab[12]; 
		duan=1;
	   	duan=0;

		P2=~weitab[7]; 
		wei=1;
		wei=0;

	   	P2=smgtab[sec%10]; 
		duan=1;
	   	duan=0;
		Delay_ms(1);
	}

}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

☆程序小黑★

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值