#include
#define uchar unsigned char
#define uint unsigned int sbit beep=P1^0; unsigned int C;
#define L1 262
#define L2 284
#define L3 311
#define L4 349
#define L5 392
#define L6 440
#define L7 494
#define Z1 523
#define Z2 587
#define Z3 659
#define Z4 698
#define Z5 784
#define Z6 880
#define Z7 987
#define H1 1046
#define H2 1174
#define H3 1318
#define H4 1396
#define H5 1567
#define H6 1760
#define H7 1975 void delay();
unsigned code GP[]={Z6,Z7,H1,Z7,H1,H3,Z7,Z3,Z6,Z5,Z6,H1,Z5,
Z3,Z3,Z4,Z3,H4,H1,Z3,H1,H1,Z7,Z4,Z4,Z7,
Z7,Z6,Z7,H1,Z7,H1,H3,Z7,Z3,Z6,Z5,Z6,H1,
Z5,Z2,Z3,Z4,H1,Z7,H1,H2,H2,H3,H1,H1,Z7,
Z6,Z6,Z7,Z5,Z6,H1,H2,H3,H2,H3,H5,H2,H1,
H1,Z7,H1,H3,H3,Z6,Z7,H1,Z7,H1,H2,H1,Z5,
Z5,H4,H3,H2,H1,H3,H3,H3,H6,H6,H5,H5,H3,
H2,H1,H1,H2,H1,H2,H5,H3,H3,H6,H6,H5,H5,
H3,H2,H1,H1,H2,H1,H2,Z7,Z6,Z6,0xff};
unsigned code JP[]={4,4,12,4,8,8,20,8,12,4,8,8,
20,4,4,12,4,8,8,20,4,4,12,4,8,8,
20,4,4,12,4,8,8,20,8,12,4,8,8,
20,4,4,8,4,12,3,1,12,4,12,4,4, 4,4,8,8,20,4,4,12,4,8,8,24,
8,4,4,8,8,24,4,4,8,4,4,8,12,4,12,
8,8,8,4,4,16,8,12,4,12,4,4,4,12,8,
12,4,8,8,16,8,12,4,12,4,4,4,12,8,
12,4,8,3,1,32};
void main()
{ uchar i,j;
TMOD=0x00;
EA=1; // 開總中斷
ET0=1; // 開 t0 中斷
while(1)
{ i=0;
while(GP[i]!=0xff)
{C=460830/GP[i]; TH0=(8192-C)/32; TL0=(8192-C)%32;
TR0=1;// 開定時器 0
for(j=0;j
{delay();} TR0=0; i++;
}
beep=0;
}
}
void delay() // 延時 15.6ms
{
uint i,j; for(i=70;i>0;i--)
{for(j=110;j>0;j--);}
}
void T0_time()interrupt 1
{ TR0=0;
beep=!beep;
TH0=(8192-C)/32;
TL0=(8192-C)%32;
TR0=1;
}