#define uchar unsigned char
#define uint unsigned int
sbit SPK=P1^0;
sbit K1=P1^7;
//发声函数,注意这里是用扬声器,不能用普通的蜂鸣器
void Alarm(uchar t)
{
uchari,j;
for(i=0;i<200;i++)
{
SPK=~SPK;
for(j=0;j
}
voidmain()
{
SPK=0;
while(1)
{
if(K1==1)
{
Alarm(90);
Alarm(120);
}
}
}