标题:
八位数码管实现某一位闪烁的方法(基于51单片机)
[打印本页]
作者:
域蓝
时间:
2019-4-5 13:50
标题:
八位数码管实现某一位闪烁的方法(基于51单片机)
8位数码管时钟显示格式为11-11-11,当如果调整时、分、秒任时,能让其中的两位数码管闪烁,其余不变。
单片机源程序如下:
#include <reg52.h>
#include "MACROANDCONST.H"
#include "DISPLAY.H"
#include "LCD.H"
sbit Shift=P2^5;
sbit Plu=P2^6;
sbit Red=P2^7;
uchar KeyNum;
void
void KeyScan()
{
if(Shift==0)
{
Delay_ms(5);
if(Shift==0)
{
KeyNum++;
while(!Shift);
if(KeyNum==1)
{
TR0=0;
WriteCommandLCD(0x80+0x44+7,1);
WriteCommandLCD(0X0f,1);
}
}
if(KeyNum==2)
{
WriteCommandLCD(0x80+0x44+4,1);
WriteCommandLCD(0X0f,1);
}
if(KeyNum==3)
{
WriteCommandLCD(0x80+0x44+1,1);
WriteCommandLCD(0X0f,1);
}
if(KeyNum==4)
{
KeyNum=0;
WriteCommandLCD(0X0c,1);
TR0=1;
}
}
if(KeyNum!=0)
{
if(Plu==0)
{
Delay_ms(5);
if(Plu==0)
{
while(!Plu);
if(KeyNum==1)
{
Miao++;
if(Miao>=60)
Miao=0;
Write_SFM(6,Miao);
WriteCommandLCD(0x80+0x44+7,1);
}
if(KeyNum==2)
{
Fen++;
if(Fen>=60)
Fen=0;
Write_SFM(3,Fen);
WriteCommandLCD(0x80+0x44+4,1);
}
if(KeyNum==3)
{
Shi++;
if(Shi>=24)
Shi=0;
Write_SFM(0,Shi);
WriteCommandLCD(0x80+0x44+1,1);
}
}
}
if(Red==0)
{
Delay_ms(5);
if(Red==0)
{
while(!Red);
if(KeyNum==1)
{
Miao--;
if(Miao<=-1)
Miao=59;
Write_SFM(6,Miao);
WriteCommandLCD(0x80+0x44+7,1);
}
if(KeyNum==2)
{
Fen--;
if(Fen<=-1)
Fen=59;
Write_SFM(3,Fen);
……………………
…………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
时钟.rar
(49.96 KB, 下载次数: 20)
2019-4-5 13:49 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
admin
时间:
2019-4-11 20:46
本帖需要重新编辑补全电路原理图,源码,详细说明与图片即可获得100+黑币(帖子下方有编辑按钮)
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1