#include<reg52.h>
void sound(int f,t);
code unsigned char sfh[]={0x00,0xF9,0xF9,0xFA,0xFA,0xFB,0xFB,0xFC,0xFC,0xFC,0xF7};
code unsigned char sfl[]={0x00,0x1F,0xDF,0x8A,0xD9,0x68,0xE9,0x5B,0x8F,0xEF,0xD1};
sbit spk=P0^0;
void main (void)
{ TMOD=0x11;
while(1)
{ sound(6,4);sound(0,1); //668542
sound(6,5);sound(0,1);
sound(8,2);sound(0,1);
sound(5,4);sound(0,1);
sound(4,2);sound(0,1);
sound(5,2);sound(0,1);
sound(2,5);sound(0,1);
//-------------------------
sound(4,2);sound(0,1);
sound(1,2);sound(0,1);
sound(10,2);sound(0,1); //6 low
sound(1,2);sound(0,1);
sound(2,2);sound(0,1);
sound(4,2);sound(0,1);
sound(5,2);sound(0,1);
sound(6,2);sound(0,1);
sound(8,2);sound(0,1);
sound(5,2);sound(0,1);
sound(6,2);sound(0,1);
sound(8,2);sound(0,1);
sound(9,2);sound(0,1);
sound(6,8);sound(0,1);
//---------------------
sound(8,5);sound(0,1);
sound(6,2);sound(0,1);
sound(5,4);sound(0,1);
sound(4,2);sound(0,1);
sound(5,2);sound(0,1);
sound(2,3);sound(0,1);
//---------------------------
sound(4,2);sound(0,1);
sound(1,2);sound(0,1);
sound(10,2);sound(0,1); //6 low
sound(1,2);sound(0,1);
sound(2,2);sound(0,1);
sound(4,2);sound(0,1);
sound(5,2);sound(0,1);
sound(6,2);sound(0,1);
sound(8,2);sound(0,1);
sound(5,2);sound(0,1);
sound(4,2);sound(0,1);
sound(5,1);sound(0,1);
sound(4,1);sound(0,1);
sound(2,2);sound(0,1);
sound(4,8);sound(0,10);
}
}
void sound(int f,t)
{
int n,l;
l=t*3;
for(n=0;n<l;n++)
{
TH0=0x4c;
TL0=0x00;
TF0=0;
TR0=1;
loop:
if (f>0)
{
TH1=sfh[f];
TL1=sfl[f];
TF1=0;
TR1=1;
spk=!spk;
}
else
{
spk=0;
}
while(TF1==0)
{}
if(TF0==0)
goto loop;
else
{
TR0=0;
TR1=0;
}
}
}