#include#define uint unsigned int
#define uchar unsigned char
sbit p2_0=P2^0;
sbit p2_2=P2^1;
sbit p2_4=P2^2;
uchar num=11;
uchar tt=0;
uchar bai,shi,ge,bai1,num1;
uchar code table[]=
{~0x3f,~0x06,~0x5b,~0x4f,
~0x66,~0x6d,~0x7d,~0x07,
~0x7f,~0x6f,~0x77,~0x7c,
~0x39,~0x5e,~0x79,~0x71};
void delay(uint z);
void main()
{
TMOD=0x01;//設(shè)置定時(shí)方式
TH0=(65536-50000)/256;//計(jì)算定時(shí)時(shí)間
TL0=(65536-50000)%6;
EA=1;// 開(kāi)總中斷
EX0=1;
IT0=1;
ET0=1; //
TR0=1; //開(kāi)啟0定時(shí)器
p2_0=1;
p2_4=1;
p2_2=1;
本文引用地址:http://m.butianyuan.cn/article/201611/321659.htmwhile(1)
//if(tt==120)
//{tt=0;
//num=10;
//}
//num=12;
shi=num/10;
ge=num;
p2_0=0;
P0=table[shi];
delay(14);
p2_0=1;
p2_2=0;
P0=table[ge];
delay(14);
p2_2=1;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void ds() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%6;
tt++;
}
//void zd() interrupt 0
//{
// num++ ;
//}
評(píng)論