Home
ProgramLanguage
DataBase
Err Window Line MEGA SEO IDE Media Google UnixTimestamp Virus
Office
OperatingSystem
MultimediaDesign
Adobe
Photoshop
Illustrator
Corel
DRAW
Painter
PaintShop
會聲會影
Pinta
GIMP
Krita Desktop
Inkscape
Arduino
有源 / 無源 蜂鳴器(Buzzer),源指的是震盪源(震盪電路)。
有源蜂鳴器內部帶有震盪電路,只要一通電就會鳴叫。
無源蜂鳴器內部不帶震盪電路,所以要用2K-5K方波驅動。

外觀
因為帶有震盪電路,所以通常有源蜂鳴器會比無源蜂鳴器大。
針腳處用黑膠封閉的是有源蜂鳴器,可以看到電路板的是無源蜂鳴器。


檢測
1.以萬用電表電阻擋測試,8Ω或16Ω是無源蜂鳴器,幾百歐姆以上是有源蜂鳴器。
2.有源蜂鳴器接額定電源可連續發聲,無源蜂鳴器需接音頻電路才能發聲。



優點
無源蜂鳴器:便宜、聲頻可控制。
有源蜂鳴器:程序控制方便。



tone()函數說明:
tone(pin, frequency)
tone(pin, frequency, duration)
pin 訊號接口, frequency,頻率,duration間距




			有源		無源
短腳		GND	-
長腳		VCC		+


int buzzer=8;                                                   //設定蜂鸣器接腳為第8孔
void setup()
{
  pinMode(buzzer,OUTPUT);                    //設定蜂鳴器為輸出
}
void loop()
{
  unsigned char i,j;                                      //定義變數
  while(1)
  {
    for(i=0;i<80;i++);                                        //發出一個频率的聲音
    {   
      digitalWrite(buzzer,HIGH);                       //發出聲音
      delay(100);                                                      //延时100ms
      digitalWrite(buzzer,LOW);                      //不發聲音
      delay(100);                                                      //延时100ms
      for(i=0;i<100;i++);                                     //發出另一個頻率的聲音
      {  
        digitalWrite(buzzer,HIGH);                      //發聲音
        delay(200);                                                     //延时200ms
        digitalWrite(buzzer,LOW);                     //不發聲音
        delay(200);                                                     //延时200ms
      }
    }
  }
}





pitches.h 
/*************************************************
 
 * Public Constants
 
 *************************************************/
#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978
 
 
 
 
 



 
單音節 
#include pitches.h
// notes in the melody: 
int melody[] = { 
   NOTE_C5, NOTE_D5, NOTE_E5, NOTE_F5, NOTE_G5, NOTE_A5, NOTE_B5, NOTE_C6}; 
int duration = 500;  // 500 miliseconds 
   
void setup() { 
} 

void loop() {   
   for (int thisNote = 0; thisNote < 8; thisNote++) { 
     // 在 pin8 上輸出聲音,每個音階響 0.5 秒 
     tone(8, melody[thisNote], duration); 
     tone(8,4699,duration);
     // 間隔一段時間後再播放下一個音階 
     delay(1000); 
   } 
   // 兩秒後重新播放  
   delay(2000); 
}






超級瑪莉
#include pitches.h
// notes in the melody : super mario

    int melodyMario[] = {

    NOTE_E4, NOTE_E4, NOTE_E4, NOTE_C4, NOTE_E4, NOTE_G4, NOTE_G3,  
    NOTE_C4, NOTE_G3, NOTE_E3, NOTE_A3, NOTE_B3, NOTE_AS3, NOTE_A3, NOTE_G3, NOTE_E4, NOTE_G4, NOTE_A4, NOTE_F4, NOTE_G4, NOTE_E4, NOTE_C4, NOTE_D4, NOTE_B3,
    NOTE_C4, NOTE_G3, NOTE_E3, NOTE_A3, NOTE_B3, NOTE_AS3, NOTE_A3, NOTE_G3, NOTE_E4, NOTE_G4, NOTE_A4, NOTE_F4, NOTE_G4, NOTE_E4, NOTE_C4, NOTE_D4, NOTE_B3,
    NOTE_G4, NOTE_FS4, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_GS3, NOTE_A3, NOTE_C4, NOTE_A3, NOTE_C4, NOTE_D4, NOTE_G4, NOTE_FS4, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_C5, NOTE_C5, NOTE_C5,
    NOTE_G4, NOTE_FS4, NOTE_E4, NOTE_DS4, NOTE_E4, NOTE_GS3, NOTE_A3, NOTE_C4, NOTE_A3, NOTE_C4, NOTE_D4, NOTE_DS4, NOTE_D4, NOTE_C4,
    NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_D4, NOTE_E4, NOTE_C4, NOTE_A3, NOTE_G3, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_D4, NOTE_E4,
    NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_D4, NOTE_E4, NOTE_C4, NOTE_A3, NOTE_G3

    };

    // note durations: 4 = quarter note, 8 = eighth note, etc.:

    int noteDurationsMario[] = {
    8,4,4,8,4,2,2,
    3,3,3,4,4,8,4,8,8,8,4,8,4,3,8,8,3,
    3,3,3,4,4,8,4,8,8,8,4,8,4,3,8,8,2,
    8,8,8,4,4,8,8,4,8,8,3,8,8,8,4,4,4,8,2,
    8,8,8,4,4,8,8,4,8,8,3,3,3,1,
    8,4,4,8,4,8,4,8,2,8,4,4,8,4,1,
    8,4,4,8,4,8,4,8,2

    };
   
 void setup() { 
     // iterate over the notes of the melody:
    for (int thisNote = 0; thisNote < 98; thisNote++) {
    // to calculate the note duration, take one second
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000/noteDurationsMario[thisNote];
    tone(8, melodyMario[thisNote],noteDuration);


    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);

    // stop the tone playing:
    noTone(8);
    }
 } 

 void loop() {   
 }








int buzzer=8;                                                   //設定蜂鸣器接腳為第8孔
int duration = 500;
int bDo = 523
int bRe = 587
int bMi = 659
int bFa = 698
int bSo = 784
int bLa = 880
int bSi = 988
int bD+o = 1047
void setup()
{
pinMode(buzzer,OUTPUT);                    //設定蜂鳴器為輸出
}
void loop()
{
  tone(8,bDo,duration);
  delay(800);
  tone(8,bRe,duration);
  delay(800);
  tone(8,bMi,duration);
  delay(800);
  tone(8,bDo,duration);
  delay(900);
  
  tone(8,bDo,duration);
  delay(800);
  tone(8,bRe,duration);
  delay(800);
  tone(8,bMi,duration);
  delay(800);
  tone(8,bDo,duration);
  delay(900);
  
  tone(8,bMi,duration);
  delay(800);
  tone(8,bFa,duration);
  delay(800);
  tone(8,bSo,duration);
  delay(900);
  
  tone(8,bMi,duration);
  delay(800);
  tone(8,bFa,duration);
  delay(800);
  tone(8,bSo,duration);
  delay(900);

  tone(8,bSo,duration);
  delay(800);
  tone(8,bRe,duration);
  delay(800);
  tone(8,bSo,duration);
  delay(800);
  tone(8,bFa,duration);
  delay(800);
  tone(8,bMi,duration);
  delay(800);
  tone(8,bDo,duration);
  delay(900);

  tone(8,bSo,duration);
  delay(800);
  tone(8,bRe,duration);
  delay(800);
  tone(8,bSo,duration);
  delay(800);
  tone(8,bFa,duration);
  delay(800);
  tone(8,bMi,duration);
  delay(800);
  tone(8,bDo,duration);
  delay(900);

  tone(8,bDo,duration);
  delay(900);
  tone(8,bSo,duration);
  delay(800);
  tone(8,bDo,duration);
  delay(900);

  tone(8,bDo,duration);
  delay(900);
  tone(8,bSo,duration);
  delay(800);
  tone(8,bDo,duration);
  delay(900);
}




//兩隻老虎
int buzzer=8;                                                   //設定蜂鸣器接腳為第8孔
int duration = 500;
int bDo = 523;
int bRe = 587;
int bMi = 659;
int bFa = 698;
int bSo = 784;
int bLa = 880;
int bSi = 988;
int bDDo = 1047;

void setup()
{
pinMode(buzzer,OUTPUT);                    //設定蜂鳴器為輸出
}
void loop()
{
  tone(8,bDo,duration);
  delay(600);
  tone(8,bRe,duration);
  delay(600);
  tone(8,bMi,duration);
  delay(600);
  tone(8,bDo,duration);
  delay(800);
  
  tone(8,bDo,duration);
  delay(600);
  tone(8,bRe,duration);
  delay(600);
  tone(8,bMi,duration);
  delay(600);
  tone(8,bDo,duration);
  delay(800);
  
  tone(8,bMi,duration);
  delay(600);
  tone(8,bFa,duration);
  delay(600);
  tone(8,bSo,duration);
  delay(800);
  
  tone(8,bMi,duration);
  delay(600);
  tone(8,bFa,duration);
  delay(600);
  tone(8,bSo,duration);
  delay(800);

  tone(8,bSo,duration);
  delay(600);
  tone(8,bLa,duration);
  delay(600);
  tone(8,bSo,duration);
  delay(600);
  tone(8,bFa,duration);
  delay(600);
  tone(8,bMi,duration);
  delay(700);
  tone(8,bDo,duration);
  delay(800);

  tone(8,bSo,duration);
  delay(600);
  tone(8,bLa,duration);
  delay(600);
  tone(8,bSo,duration);
  delay(600);
  tone(8,bFa,duration);
  delay(600);
  tone(8,bMi,duration);
  delay(700);
  tone(8,bDo,duration);
  delay(800);

  tone(8,bDo,duration);
  delay(700);
  tone(8,bSo,duration);
  delay(700);
  tone(8,bDo,duration);
  delay(800);

  tone(8,bDo,duration);
  delay(700);
  tone(8,bSo,duration);
  delay(700);
  tone(8,bDo,duration);
  delay(800);
  delay(2000);
}





低音:


音调

音符
 
1#
 
2#
 
3#
 
4#
 
5#
 
6#
 
7#
 

A
 
221
 
248
 
278
 
294
 
330
 
371
 
416
 

B
 
248
 
278
 
294
 
330
 
371
 
416
 
467
 

C
 
131
 
147
 
165
 
175
 
196
 
221
 
248
 

D
 
147
 
165
 
175
 
196
 
221
 
248
 
278
 

E
 
165
 
175
 
196
 
221
 
248
 
278
 
312
 

F
 
175
 
196
 
221
 
234
 
262
 
294
 
330
 

G
 
196
 
221
 
234
 
262
 
294
 
330
 
371
 

 

中音:


音调

音符
 
1
 
2
 
3
 
4
 
5
 
6
 
7
 

A
 
441
 
495
 
556
 
589
 
661
 
742
 
833
 

B
 
495
 
556
 
624
 
661
 
742
 
833
 
935
 

C
 
262
 
294
 
330
 
350
 
393
 
441
 
495
 

D
 
294
 
330
 
350
 
393
 
441
 
495
 
556
 

E
 
330
 
350
 
393
 
441
 
495
 
556
 
624
 

F
 
350
 
393
 
441
 
495
 
556
 
624
 
661
 

G
 
393
 
441
 
495
 
556
 
624
 
661
 
742
 

 

高音:


音调

音符
 
1#
 
2#
 
3#
 
4#
 
5#
 
6#
 
7#
 

A
 
882
 
990
 
1112
 
1178
 
1322
 
1484
 
1665
 

B
 
990
 
1112
 
1178
 
1322
 
1484
 
1665
 
1869
 

C
 
525
 
589
 
661
 
700
 
786
 
882
 
990
 

D
 
589
 
661
 
700
 
786
 
882
 
990
 
1112
 

E
 
661
 
700
 
786
 
882
 
990
 
1112
 
1248
 

F
 
700
 
786
 
882
 
935
 
1049
 
1178
 
1322
 

G
 
786
 
882
 
990
 
1049
 
1178
 
1322
 
1484
 







Do(523Hz), Re (587Hz), Mi(659Hz), Fa(698Hz), So(784Hz), La(880Hz), Si(988Hz) 到高音 Do (1047Hz)



電壓:電磁式、壓電式

電流

驅動方式

尺寸

連接/固定方式

| 關於我們 | 聯絡我們 | 更新記錄 |
版權所有 轉載必究 服務專線: