|
#include<reg51.h>
sbit SPK=P1^0;
sbit key1=P2^0;
sbit key2=P2^5;
void delay1000Hz(void);
void delay(unsigned int xms);
void delay500Hz(void);
void delay1000Hz(void)
{
unsigned int i;
for(i=0;i<167;i++);
}
void delay500Hz(void)
{
unsigned int i;
for(i=0;i<83;i++);
}
int main(){
while(1){
if(key1 == 0){
SPK=0;
delay1000Hz();
SPK=1;
delay1000Hz();
}
if(key2==0){
SPK=0;
delay500Hz();
SPK=1;
delay500Hz();
}
}
return 0;
}
|
|