当前位置:首页 > MCU > CT107D > 正文内容

CT107D 数码管动态显示

chanra1n4年前 (2020-10-16)CT107D3611
#include<reg52.h>
#include<intrins.h>
void hdw_init();
void smg_refresh();
void Delay1ms();
unsigned char num[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char duan[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
unsigned char smg[8]={1,2,3,4,5,6,7,8};
unsigned char x;
void main()
{
	hdw_init();
	while(1)
	{
		smg_refresh();
	}
}
void Delay1ms()		//@12.000MHz
{
	unsigned char i, j;

	i = 12;
	j = 169;
	do
	{
		while (--j);
	} while (--i);
}

void hdw_init()
{
	P2=0xA0;
	P0=0x00;
	P2=0x00;
	
	P2=0x80;
	P0=0xFF;
	P2=0x00;
}
void smg_refresh()
{
	for(x=0;x<8;x++)
	{
		P2=0xC0;
		P0=duan[x];
		P2=0x00;
		
		P2=0xE0;
		P0=num[smg[x]];
		Delay1ms();
		P0=0xFF;
		P2=0x00;
	}
}

核心代码讲解

void smg_refresh()
{
	for(x=0;x<8;x++)
	{
		P2=0xC0;
		P0=duan[x];
		P2=0x00;
		
		P2=0xE0;
		P0=num[smg[x]];
		Delay1ms();
		P0=0xFF;
		P2=0x00;
	}
}

P2=0xC0;使得Y6C被选通,然后就可以选择指定的数码管进行显示


P2=0xE0;   使得Y7C被选通,然后就可以发送需要显示的值到指定的数码管


                P0=num[smg[x]];
		Delay1ms();
		P0=0xFF;
		P2=0x00;


扫描二维码推送至手机访问。

版权声明:本文由我的FPGA发布,如需转载请注明出处。

本文链接:https://www.myfpga.cn/index.php/post/151.html

分享给朋友:

“CT107D 数码管动态显示” 的相关文章

CT107D-串口通信

CT107D-串口通信

串口通信能用到的寄存器:SCON PCON TMODSCON Serial Control Register 串口控制寄存器 0x98HSCON的各位定义及作用SM0    SM1    SM2 &n...

CT107D DAC 电压模拟输出

CT107D DAC 电压模拟输出

/*   程序说明: IIC总线驱动程序   软件环境: Keil uVision 4.10    硬件环境: CT107单片机综合实训平台 8051,12MHz...