Tag Archives: buzzer

Seg 2: Experiment, principle, and code

5.4 Experimental principle

The principle is simple in this experiment, which is summarized as follows. The buzzer can make a sound, since the current on the buzzer is powered on the electromagnetic coil, which can make coil generate magnetic field. Then it can drive vibrating diaphragm to generate a sound. This is the reason why the buzzer must need the current. Its schematic principle is drawn in Figure 5-3. In our such experiment, port 9 on the Arduino board can provide a voltage for the passive buzzer. Then it can generate a sound. It is worth noting that, the rated voltage for the buzzer is 5V, while the Arduino’s max voltage is 5V as well. Therefore, the circuit cannot connect serially a resistor. If connected, then the buzzer doesn’t work.

5.5 Experiment and code

In fact, the circuit connection of such experiment is very simple, which is seen in Figure 5-3. After run Program 5, Arduino can generate alarm sound.


Figure 5-3 Experimental circuit

01 // Program 5: how to use Arduino and buzzer generate alarm sound
02 
03 void setup()
04 {
05 }
06  
07 void loop()
08 {
09 for(int i=200;i<=800;i++)   // frequency from 200Hz to 800Hz
10 {
11   pinMode(4,OUTPUT);
12   tone(4,i);       //output frequency at port 4, i.e., generate a sound
13  delay(5);       //generate a sound for 5ms 
14 }
15 delay(4000);           //the highest frequency lasts for 4ms
16 for(int i=800;i>=200;i)
17 {
18   pinMode(4,OUTPUT);
19   tone(4,i);
20  delay(10);
21 }
22 }

Here, a new Arduino function “tone” is introducted. Its syntax is:

tone(pin, frequency)

tone(pin, frequency, duration)

where,

pinwhich is defined on the Arduino board

frequency: the voice frequency, unit is Hz, unsigned int

durationvoice lasting time, unit is ms (optional), unsigned long

5.6 Key points and summaries

1) The buzzer can be divided into active and passive. The active one can make a sound by directly connecting power, while the passive one can generate a sound only for the changing frequency. Therefore, the buzzer can make a sound on the Arduino board by PWM technique. But, it cannot connect serially a resistor.

2) The principle of buzzer is that, when the current passes through the electromagnetic coil, it will generate a magnetic field, which can drive the vibrating diaphragm make a sound periodically.

Seg 1: Buzzer introduction

5.1 Problem presentation: how to use Arduino and buzzer to imitate alarm song

This sample is similar to the fourth experiment, which are all use PWM technique. This is because voice is an analog signal. So, if you still use the code in experiment 4, you can listen the voice.

5.2 The required materials

The required materials are very simple. It is just change the LED into buzzer, and the resistor doesn’t be used. Since the voltage is also 5V, the buzzer might not make a sound if a resistor increases. The required materials are shown in Table 5-1.

Table 5-1: Materials

The required materials

Number

Name Quality Function Note

1

Arduino software 1 suit Provide ide New ver 1.05

2

Arduino UNO board 1 Control board Many

3

USB data line 1 Connect board distribution

4

Dupont line 2 Connect elements optional

5

buzzer 1 LED blink optional

7

Bread board Connection optional

The real material could be seen in Figure 5-3.

5.3 Elements introduction

Buzzer can be divided into piezoelectric and electromagnetic ones by its structure. The electromagnetic buzzer is composed of oscillator, the electromagnetic coil, magnets, diaphragm and shell vibration. After power on, the oscillator in buzzer can generate the audio signal current, which then make the electromagnetic coil generate the magnetic field. So, Vibrating diaphragm can periodically make a sound under the interaction of electromagnetic coil and magnet.

Additionally, buzzer can be divided into active and passive ones by the signal source. As for the active buzzer, if the rated voltage is put, then the periodic frequency signal can be generated at the inside of oscillator. The periodic signal can drive the buzzer voice. While as for the passive buzzer, it can be viewed as a horn. If and only if a changing electronic signal is added onto the buzzer, it can make a sound. Their model can be shown in Figure 5-1.



  1. Passive buzzer (b) active buzzer

 

Figure 5-1 Buzzer

We can make the difference between the passive and active buzzers by the following three methods.

  1. From the shapes of buzzer shown in Figure 5-1 (a)(b), the two buzzers are so similar to each other in shape that it is difficult to recognize them. But, if careful, we know that the height of the two buzzers is different. The passive is 8mm in Figure 5-1(a), while the active is 9mm in Figure 5-1(b).
  2. if the pins are above, the green board is passive buzzer, while the other is active one, whose board is closed by the black sheet.
  3. the more scientific method is by using multimeter with resistance Rx1. Let the black pen in multimeter connect the “+” pin of buzzer, and the red pen touch to and fro the other pin. If we listen the “ka…ka” sound and the resistance value is only 8Ω or 16Ω, then this buzzer is passive; if we listen the continuous sound and the resistance value is more than hundreds of ohm (Ω), then this buzzer is active.

Note that, the active buzzer can make a sound continuously by connected a rated power, which is labeled on the new version buzzer; while the passive is similar to an electromagnetic speaker, which must be connected an audio circuit, the buzzer can make sound. Additionally, as shown in Figure 5-2(a), a symbol “+” is labeled on the passive buzzer. But during the experiment, the passive buzzer can make a sound regardless of the positive or negative polarity on the Arduino board. Generally speaking, we had better do the corresponding experiment by the label.


Figure 5-2 Circuit schematics