当前位置:首页 » 编程软件 » 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++;
}

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

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:572
制作脚本网站 发布:2025-10-20 08:17:34 浏览:860
python中的init方法 发布:2025-10-20 08:17:33 浏览:559
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:740
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:660
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:981
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:232
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:90
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:783
python股票数据获取 发布:2025-10-20 07:39:44 浏览:688