#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit ext0=P3^0;
uchar k;
uchar i;
delay10ms()
{
uchar t,h;
for(t=20;t>0;t--)
for(h=250;h>0;h--);
}
uchar code shuzu[]={0xc0,0xf9, 0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
main()
{
TMOD=0x01;
TH0=(65536-46080) /256;
TL0=(65536-46080) %256;
ET0=1;
IT0=0;
EX0=1;
EA=1;
TR0=1;
while(1);
}
void ext_0()interrupt 0
{
delay10ms();
if(ext0==0)
{
P2=shuzu
;
if(k==20)
{i++;k=0;
if(i==10)
{i=0;
}
}
}
}
void tim_0()interrupt 1
{
TH0=(65536-46080) /256;
TL0=(65536-46080) %256;
k++;
}
一周热门 更多>