当前位置:首页 » 编程软件 » 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 05:52:09 浏览:651
移动版我的世界服务器 发布:2025-09-18 05:38:49 浏览:958
使用jsp脚本输出九九乘法表 发布:2025-09-18 05:22:11 浏览:663
出行解压 发布:2025-09-18 05:20:54 浏览:574
安卓手机画线怎么用 发布:2025-09-18 05:16:43 浏览:697
解压吃蔬菜 发布:2025-09-18 05:10:04 浏览:818
php判断数组个数 发布:2025-09-18 04:54:02 浏览:665
linuxmd5c 发布:2025-09-18 04:47:04 浏览:345
数据结构编译器哪个好 发布:2025-09-18 04:33:52 浏览:437
ad转换c语言 发布:2025-09-18 04:21:21 浏览:755