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

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

热点内容
数据结构编译器哪个好 发布:2025-09-18 04:33:52 浏览:435
ad转换c语言 发布:2025-09-18 04:21:21 浏览:752
sqlserver2008设置外键 发布:2025-09-18 04:21:12 浏览:114
服务器电脑电源管理 发布:2025-09-18 03:52:33 浏览:324
叉叉助手删除脚本 发布:2025-09-18 03:21:24 浏览:851
深圳ug五轴编程培训 发布:2025-09-18 03:13:35 浏览:197
安卓软件残留怎么清理 发布:2025-09-18 03:02:02 浏览:345
centos7apachephp7 发布:2025-09-18 03:01:47 浏览:657
安卓如何实现点击弹出列表 发布:2025-09-18 02:47:25 浏览:58
python文件函数 发布:2025-09-18 02:47:23 浏览:574