主函数
#include <REGX52.H>
#include "Delay.h"
#include "Key.h"
#include "Nixie.h"
#include "Buzzer.h"
sbit Buzzer=P2^5;
unsigned char KeyNum;
unsigned int i;
void main()
{
Nixie(1,0);
while(1)
{
KeyNum=Key();
if(KeyNum)
{
Buzzer_Time(1000);
Nixie(1,KeyNum);
}
}
}
Buzzer
#include <REGX52.H>
#include <intrins.h>
#include "delay.h"
sbit Buzzer=P2^5;//蜂鸣器端口
/**
* @brief 蜂鸣器私有延时函数,延时500us
* @param 无
* @retval 无
*/
void Buzzer_Delay500us() //@12.000MHz
{
unsigned char i;
_nop_();
i = 247;
while (--i);
}
/**
* @brief 蜂鸣器发声
* @param ms 发声的时长
* @retval 无
*/
void Buzzer_Time(unsigned int ms)
{
unsigned int i;
for(i=0;i<ms*2;i++)
{
Buzzer=!Buzzer;
Buzzer_Delay500us();
}
}
Delay
void Delay(un