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

CT107D 数码管动态显示

chanra1n4年前 (2020-10-16)CT107D3617
#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://myfpga.cn/index.php/post/151.html

分享给朋友:

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

CT107D-流水灯(跑马灯的简单实现)

CT107D-流水灯(跑马灯的简单实现)

#include <reg52.h> #include <intrins.h> sbit relay=P0^4;   //继电器 sbit buzzer=P0^6;  //蜂鸣器...

CT107D DS1302

CT107D DS1302

使用官方的ds1302.h和ds1302.c,下方有核心代码讲解main.c#include<reg52.h> #include<intrins.h> #include<ds1302.h> typedef unsigned char&nb...

CT107D 频率计  蓝桥杯频率测量 可以测量0-65khz方波

CT107D 频率计 蓝桥杯频率测量 可以测量0-65khz方波

基于STC的官方示例文件完成编写,推荐STC单片机,性能稳定 使用时请使用杜邦线连接P3_2引脚和555发生的SIGNAL引脚#include "reg51.h" #include "intrins.h" typedef&nb...