在这个程序里加一个控制按键,按键按下流水灯和蜂鸣器开始运行,再按下停止运行!可以的话帮我把蜂鸣器发出的声音改成节奏报警!谢谢
#include
#include
#define uchar unsigned char
#define uint unsigned int
sbit beep = P2^7; // P1.2口控制蜂鸣器
Delay(uint);
unsigned int a,b;
unsigned char c;
void delay(unsigned char);
main ()
{
c=0xfe;
while(1)
{
P1=c;
beep=0;
delay(10);
beep=1;
delay(10);
c=_crol_(c,1);
}
}
void leday(unsigned char x)
{
for(a=500;a>0;a--)
for(b=x;b>0;b--);
}
Delay(uint z) //含有发音功能的延时程序
{
uint i, j;
for(j = z; j > 0; j--) {
beep = 0; for(i = 100; i > 0; i--);
beep = 1; for(i = 100; i > 0; i--);
}
}