#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uint num1,num,i,j;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
sbit dula=P2^6;
sbit wela=P2^7;
uchar shi,ge;
void delay(xms)
{
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void main()
{
TMOD=0x01;
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
EA=1;
ET0=1;
TR0=1;
dula=1;
P0=table[shi];
dula=0;
delay(5);
wela=1;
P0=0xfe;
wela=0;
delay(5);
dula=1;
P0=table[ge];
dula=0;
delay(5);
wela=1;
P0=0xfd;
wela=0;
delay(5);
}
void T1_time()interrupt 1
{
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
num1++;
if(num==20)
{
num1=0;
num++;
if(num==99)
{
num=0;
}
shi=num/10;
ge=num%10;
}
}
此帖出自
小平头技术问答
一周热门 更多>