蜂鸣器介绍
•蜂鸣器是一种将电信号转换为声音信号的器件,常用来产生设备的按键音、报警音等提示信号
•蜂鸣器按驱动方式可分为有源蜂鸣器和无源蜂鸣器
•有源蜂鸣器:内部自带振荡源,将正负极接上直流电压即可持续发声,频率固定
•无源蜂鸣器:内部不带振荡源,需要控制器提供振荡脉冲才可发声,调整提供振荡脉冲的频率,可发出不同频率的声音
驱动电路
1)三极管驱动
2)集成电路驱动
ULN2003介绍
逻辑框图
典型应用电路
按键提示音
1)程序
#include <REGX52.H>
#include "Delay.h"
#include "Key.h"
#include "Nixie.h"
#include "Buzzer.h"
unsigned char KeyNum;
void main()
{
Nixie(1,0);
while(1)
{
KeyNum=Key();
if(KeyNum)
{
Buzzer_Time(100);
Nixie(1,KeyNum);
}
}
}
Nixie.c
#include <REGX52.h>
#include "Delay.h"
unsigned char NixieTable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f0,0x6f};
void Nixie(unsigned char Location , Number)
{
switch(Location)
{
case 1:P2_4 = 1;P2_3 = 1;P2_2=1;break;
case 2:P2_4 = 1;P2_3 = 1;P2_2=0;break;
case 3:P2_4 = 1;P2_3 = 0;P2_2=1;break;
case 4:P2_4 = 1;P2_3 = 0;P2_2=0;break;
case 5:P2_4 = 0;P2_3 = 1;P2_2=1;break;
case 6:P2_4 = 0;P2_3 = 1;P2_2=0;break;
case 7:P2_4 = 0;P2_3 = 0;P2_2=1;break;
case 8:P2_4 = 0;P2_3 = 0;P2_2=0;break;
}
P0 = NixieTable[Number];
// Delay(1);
// P0=0x00;
}
2)Proteus仿真