#include
#define uchar unsigned char
uchar table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f};
sbit speaker=P2^0;
void delay()//延时约400毫秒
{
uchar i,j;
for(i=0;i<200;i++)
for(j=0;j<250;j++);
}
main()
{
uchar i,times=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
P2=0xff;
while(1)
{
if(TF0==1)
{
TF0=0;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
times++;
if(times>=20)
{
times=0;
P1=table[i];
i++;
i%=10;
speaker=0;
delay();
speaker=1;
}
}
}
}
固定字位,输出字型,响一次,延时,关蜂鸣器,延时,输出下一个字型........