1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > 单片机数码管显示程序c语言 基于STC89C52单片机的动态数码管显示C语言程序

单片机数码管显示程序c语言 基于STC89C52单片机的动态数码管显示C语言程序

时间:2018-07-30 15:04:37

相关推荐

单片机数码管显示程序c语言 基于STC89C52单片机的动态数码管显示C语言程序

* 实验说明 : 8位数码管显示0~F

#include

#define GPIO_DIG P0 //段选

#define GPIO_PLACE P1 //位选

//--定义全局变量--//

unsigned char code DIG_PLACE[8] = {

0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//位选控制 查表的方法控制 unsigned char code DIG_CODE[17] = {

0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,

0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71 };

//0、1、2、3、4、5、6、7、8、9、A、b、C、d、E、F的显示码 unsigned char DisplayData[8];

//用来存放要显示的8位数的值

void DigDisplay(); //动态显示函数

void main(void)

{

unsigned char i;

for(i=0; i<8; i++)

{

DisplayData[i] = DIG_CODE[i];

}

while(1)

{

DigDisplay();

}

}

void DigDisplay()

{

unsigned char i;

unsigned int j;

for(i=0; i<8; i++)

{

GPIO_PLACE = DIG_PLACE[i]; //发送位选

GPIO_DIG = DisplayData[i]; //发送段码

j = 10; //扫描间隔时间设定

while(j--);

GPIO_DIG = 0x00;//消隐

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。