1.蜂鸣器的介绍

无源蜂鸣器不能一直通电,无源蜂鸣器内部的线圈较小,易烧坏
蜂鸣器的驱动

达林顿晶体管(npn型)

应用:
按下独立按键同时蜂鸣器响起提示音,数码管显示对应的独立按键键码
- #include <REGX52.H>
- #include "Delay.H"
- #include "Key.H"
- #include "Nixie.H"
-
- sbit BEEP=P2^5;
-
- unsigned char KeyNum;
- unsigned int i;
-
- void main()
- {
- Nixie(1,0);
- while(1)
- {
- KeyNum=Key();
- if(KeyNum)
- {
- for(i=0;i<500;i++)
- {
- BEEP=!BEEP;
- Delay(1);
- }
- Nixie(1,KeyNum);
-
- }
-
- }
-
- }
原理图

