当前位置:首页 » 编程软件 » led数码管编程

led数码管编程

发布时间: 2023-09-20 16:17:08

㈠ 谁能告诉我51单片机简单的led数码管时钟程序 24小时制的(c语言版的)

#include "reg52.h"
#define uint unsigned int
#define uchar unsigned char
uchar code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar shi,fen,miao;
uchar time;
void delay(uint x)
{
uint y;
for(;x>0;x--)
{
for(y=0;y<124;y++);
}
}
void display(uchar shi,uchar fen,uchar miao)
{
P2=0; //位码
P0=(tab[shi/10]); //段码
delay(2);
P2=1;
P0=(tab[shi%10]);
delay(2);
P2=2; //位码
P0=0x40; //段码
delay(2);
P2=3; //位码
P0=(tab[fen/10]); //段码
delay(2);
P2=4;
P0=(tab[fen%10]);
delay(2);
P2=5; //位码
P0=0x40; //段码
delay(2);
P2=6; //位码
P0=(tab[miao/10]); //段码
delay(2);
P2=7;
P0=(tab[miao%10]);
delay(2);

}
void main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{

if(time==20)
{
time=0;
miao++;
if(miao==60)
{
miao=0;
fen++;
if(fen==60)
{
fen=0;
shi++;
if(shi==24)
shi=0;
}

}

}
display(shi,fen,miao);
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
time++;
}

/*还有什么不明白继续追加*/

热点内容
matlab粒子群优化算法 发布:2025-03-07 08:13:49 浏览:247
编译原理翻译 发布:2025-03-07 08:08:01 浏览:590
安卓光遇测试服为什么服务器错误 发布:2025-03-07 08:05:53 浏览:548
火狐缓存文件夹 发布:2025-03-07 08:05:51 浏览:110
代码编程库 发布:2025-03-07 08:05:09 浏览:179
js远程脚本 发布:2025-03-07 07:54:31 浏览:2
linux修改用户目录 发布:2025-03-07 07:46:24 浏览:459
六个文件夹名称 发布:2025-03-07 07:45:28 浏览:851
华威随身网络的密码是什么 发布:2025-03-07 07:43:07 浏览:667
我的世界服务器生存怎么改创造 发布:2025-03-07 07:39:53 浏览:790