Buzzer

From SainSmart Wiki
Revision as of 09:23, 16 July 2013 by Admin (Talk | contribs)

Jump to: navigation, search

Buzzer

What’s buzzer?

The buzzer is one integrated electronic transducers, DC voltage supply, widely used in computers, printers, copiers, alarm, electronic toys, automotive electronic equipment, telephones, timers and other electronic products for sound devices.

QQ图片20130716172058.jpg

They can be divided into the: active buzzer (containing driver line) and passive buzzer (external drive) in their drive different way, teach you to distinguish between active buzzer and passive buzzer. A small buzzer for sale on the market now because of its small size (diameter is only 11mm), light weight, low price, solid structure, while widely used in various electrical equipment with sound, electronic production and microcontroller circuits. Appearance of active the buzzer and passive buzzer like a, b shown. a) active b) passive.

QQ图片20130716172124.jpg

From the figure a, b appearance watching, the two buzzers seems to the same, but a closer look, the height of the two slight difference active buzzer a height of 9mm, passive buzzer b, a height of 8 mm. As facing up to two buzzers’ pin County it can be seen that there are a green circuit board is passive buzzer, no circuit board using vinyl enclosed one is active buzzer. Further determine the active and passive buzzer multimeter resistance profile Rxl file test: use a black pen touch buzzer’s pin "+", red pen touch in the other pin back and forth, If you feel a click, cracking sound and resistance is only 8Ω (Or 16Ω) which is a passive buzzer; continuing sound can issue, and the resistance is more than hundreds of Europe that is active buzzer. Active buzzer directly connected to the rated power (indicate on the new buzzer’s label) can be continuous sound; rather passive buzzer and electromagnetic speaker needs to be connected to the audio output circuit can vocalization. Buzzer also can be divided into according to the constructed different,: the electromagnetic buzzer and piezoelectric buzzer;

Connect your circuit as the below diagram.

The buzzer used in this experiment with the internal drive. Circuit the buzzer positive connect directly into the digital port 13. GND socket connected to the negative terminal of the buzzer. File:Example.jpg

Buzzer analog ambulance siren sound experiment

Experiment component:

Buzzer : 1 Breadboard & Jumper wires

Connect your circuit as the below diagram.

File:Example.jpg

Example code

int buzzer=7;//set buzzer’s digital pin IO in control void setup() {

 pinMode(buzzer,OUTPUT);//set digital pin IO OUTPUT

} void loop() {

 unsigned char i,j;//define i j
 while(1)
   { 
   for(i=0;i<80;i++)// Output a frequency of sound
       { 
     digitalWrite(buzzer,HIGH);//sound
     delay(1);//delay 1ms
     digitalWrite(buzzer,LOW);//mute
     delay(1);//delay 1ms 
       } 
   for(i=0;i<100;i++)// Output the other frequency of sound
       { 
     digitalWrite(buzzer,HIGH);//sound
     delay(2);//delay 2ms
     digitalWrite(buzzer,LOW);//mute
     delay(2);//delay 2ms
       } 
   } 

}

while loops Description while loops will loop continuously, and infinitely, until the expression inside the parenthesis, () becomes false. Something must change the tested variable, or the while loop will never exit. This could be in your code, such as an incremented variable, or an external condition, such as testing a sensor.

Syntax while(expression){

 // statement(s)

}

Parameters expression - a (boolean) C statement that evaluates to true or false

Example var = 0; while(var < 200){

 // do something repetitive 200 times
 var++;