C51-秒表0到99

lemon Lv5

第九篇

0-99循环显示,每隔一秒,增加1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include  "reg51.h"

void delay1s()
{
unsigned char i;
for(i=0;i<1;i++){
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
TR1=1;
while(!TF1);
TF1=0;
}
}

void disp(unsigned char i)
{
unsigned int k;
unsigned char led[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90} ;
for ( k = 0; k < 50; k++)
{
P2=0xe7;
P0=~led[i/10];
delay1s();
P2=0xe3;
P0=~led[i%10];
delay1s();
}
}
void main()
{
unsigned char miao=0;
TMOD=0x10;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TR1=1;
while(1){
disp(miao);
miao++;
if(miao==100)miao=0;
}
}


代码下载链接(123云盘):https://www.123684.com/s/wFuijv-i8Zgh

  • 标题: C51-秒表0到99
  • 作者: lemon
  • 创建于 : 2025-07-22 22:02:53
  • 更新于 : 2025-07-23 00:11:30
  • 链接: https://lemon2003.github.io/post/20250722220253.html
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
C51-秒表0到99