51单片机实现数码管滚动显示

#include <REGX51.H>
void main()
{
	const unsigned char design[16]={0xc0,0xf9,0xa4,0xb0,0x99,0x82,0xf8,0x80,0x90};//0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}
	unsigned char DisplayBuffer[8]={1,2,3,4,5,6,7,8};
	unsigned int a;
	unsigned char b;
	unsigned char w;
	unsigned char w1=0;
	unsigned int t=0;
	unsigned int t1=0;
	do{
		w=254;
		for(b=0;b<8;b++)
		{
			for(a=0;a<500;a++);
			P0=255;
			
			if(b<t1)
			P2=~design[DisplayBuffer[b]];
			else if(b+w1<8+t1)
				P2=0;
			else if(b+w1>8+t1)P2=0;
			else
				P2=~design[DisplayBuffer[b+w1-8]];

			P0=w;
			w =(w<<1)+1;
		}
		if(t++>7)
		{	if(w1++>7)
			{
				if(t1++>7)
					t1=0;
				w1=0;
			}
			t=0;
		}

	}while(1);

}

在这里插入图片描述

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页