#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit LED1=P0^3;
sbit LED2=P0^5;
sbit LED3=P0^7;
sbit LED4=P2^7;
sbit beep=P2^4;
unsigned int C;
unsigned int f=500;
unsigned int g=0;
#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();
void Delay(unsigned int t);
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; //
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<JP[i];j++)
{
delay();
}
TR0=0;
i++;
}
/****μÆ*///
/*f=500,g=0;
LED1=1;
Delay(100);
for(g=1;g<f;g++)
{
LED1=0;//0 ê??e
Delay(g);
LED1=1;
Delay(f-g);
}
// C=500,PWM=0;
LED1=0;
Delay(100);
for(g=1;g<f;g++)
{
LED1=1;
Delay(g);
LED1=0;
Delay(f-g);
}*/
}
beep=0;
}
void delay() //??15.6ms
{
uint i,j;
for(i=70;i>0;i--)
{for(j=110;j>0;j--);}
}
/**********¶¨ê±Æ÷0**òôàÖ********/
void T0_time()interrupt 1
{
TR0=0;
beep=!beep;
TH0=(8192-C)/32;
TL0=(8192-C)%32;
TR0=1;
}
void Delay(unsigned int t)
{
while(--t);
}
|