发布网友 发布时间:2022-04-24 15:27
共1个回答
热心网友 时间:2023-10-19 06:21
#include<reg52.h>
#define
uchar
unsigned
char
#define
uint
unsigned
int
uchar
count;
uint
disnum;
sbit
la=P2^6;
sbit
wela=P2^7;
uchar
code
table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
display(uchar,uchar,uchar);
delay(uchar);
void
main()
{
EA=1;
ET1=1;
TMOD=0x10;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TR1=1;
while(1)
{
if(count==20)
{
count=0;
//
if(disnum==1000)
//
disnum=0;
disnum++;
}
display(disnum/100,disnum%100/10,disnum%100%10);
}
}
void
tim1()
interrupt
3
using
3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
count++;
}
display(uchar
,uchar
shi,uchar
ge)
{
P0=table[];
la=1;
la=0;
P0=0xfe;
wela=1;
wela=0;
delay(1);
P0=table[shi];
la=1;
la=0;
P0=0xfd;
wela=1;
wela=0;
delay(1);
P0=table[ge];
la=1;
la=0;
P0=0xfb;
wela=1;
wela=0;
delay(1);
}
delay(uchar
x)
{
uchar
a,b;
for(a=x;a>0;a--)
for(b=255;b>0;b--);
}
//你自己看一下,有不对的就改点.别忘了给分啊