作者:王开心
main.c
#include <REGX52.H>
#include "Delay.h"
#include "Key.h"
#include "Nixie.h"
#include "Timer0.h"
#include "Buzzer.h"
unsigned char KeyNum ;
void main()
{
Nixie(1,0);
while(1)
{
KeyNum = Key();
if(KeyNum)
{
Buzzer_Timer(100);
Nixie(1,KeyNum);
}
}
}
Buzzer.c
#include "Buzzer.h"
#include "intrins.h"
#include <REGX52.H>
sbit Buzzer = P2^5; //蜂鸣器位声明
/**
* @brief 蜂鸣器私有延时函数 延时500us
* @param 无
* @retval 无
*/
void Buzzer_Delay500us() //@11.0592MHz
{
unsigned char i;
_nop_();
i = 227;
while (--i);
}
/**
* @brief 蜂鸣器发声
* @param 发生的延时
* @retval
*/
void Buzzer_Timer(unsigned int ms)
{
unsigned int i;
for(i=0; i<ms*2; i++)
{
Buzzer = !Buzzer;
Buzzer_Delay500us();
}
}
标签:Buzzer,蜂鸣器,void,51,unsigned,提示音,KeyNum,include
From: https://blog.csdn.net/qq_58662017/article/details/142133702