⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 led.bak

📁 数码管动态显示(C51,C文件)有所有文件级编译文件
💻 BAK
字号:
#include <reg52.h>

code unsigned char seg7code[10]={0x3f,0x06,0x5b,0x4f,
                                 0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //显示段码
void Delay(unsigned int tc)     //延时程序
{
	while( tc != 0 )			//如果tc为0则终止延时
	{
		unsigned int i;			//局部正整数变量 i
		for(i=0; i<100; i++);	//执行400次将耗时1毫秒
		tc--;					//tc计数减一
	}
}

void Led(int date)
{
   P2=P2&0x7f;             //P2.7输出低电平,选通千位数
   P0=seg7code[date/1000]; //取出千位数,查表,输出。
   Delay(8);              //延时
	P2=P2|0xf0;            //销隐
	P2=P2&0xbf;                //P2.6输出低电平,选通百位数
   P0=seg7code[date%1000/100]; //取出百位数,查表,输出。
	Delay(8);                 //延时
	P2=P2|0xf0;                //销隐
	P2=P2&0xdf;                //P2.5输出低电平,选通十位数
   P0=seg7code[date%100/10];    //取出十位数,查表,输出。
	Delay(8);                 //延时
	P2=P2|0xf0;                //销隐
	P2=P2&0xef;
   P0=seg7code[date%10];        //取出个位数,查表,输出。
   Delay(8);
   P2=P2|0xf0;
}

main()
{ 
  
  int t=6347; //定义并赋值要显示的数据
  while(1)
  {
   Led(t);//调用显示函数显示数据t
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -