Introduction
Buzzers can be categorized as active and passive ones (See the following picture).
![](https://learn.sunfounder.com/wp-content/uploads/2020/10/image-1699.png)
Required Components
– 1 * Raspberry Pi
– 1 * Breadboard
– 1 * Passive buzzer module
– 1 * Active buzzer module
– 1 * 3-Pin anti-reverse cable
Experimental Principle
Place the pins of two buzzers face up and you can see the one with a green circuit board is a passive buzzer, while the other with a black tape, instead of a board, is an active buzzer.
![](https://learn.sunfounder.com/wp-content/uploads/2020/10/image-1701.png)
The difference between an active buzzer and a passive buzzer is:
An active buzzer has a built-in oscillating source, so it will make sounds when electrified. But a passive buzzer does not have such source, so it will not beep if DC signals are used; instead, you need to use square waves whose frequency is between 2K and 5K to drive it. The active buzzer is often more expensive than the passive one because of multiple built-in oscillating circuits.
The schematic diagram of the module is as shown below:
![](https://learn.sunfounder.com/wp-content/uploads/2020/10/image-1703.png)
Experimental Procedures
Active Buzzer
Note:
The active buzzer has built-in oscillating source, so it will beep as long as it is wired up, but it can only beep with fixed frequency.
Step 1: Build the circuit.
![](https://learn.sunfounder.com/wp-content/uploads/2020/10/image-1705.png)
For C Users:
Step 2: Change directory.
cd /home/pi/SunFounder_SensorKit_for_RPi2/C/10_active_buzzer/
Step 3: Compile.
gcc active_buzzer.c -lwiringPi
Step 4: Run.
sudo ./a.out
For Python Users:
Step 2: Change directory.
cd /home/pi/SunFounder_SensorKit_for_RPi2/Python/
Step 3: Run.
sudo python3 10_active_buzzer.py
Now you can hear the active buzzer beeping.
![](https://learn.sunfounder.com/wp-content/uploads/2020/10/image-1707.png)
Passive Buzzer
Step 1: Build the circuit.
Raspberry Pi | GPIO Extension Board | Passive Buzzer Module |
GPIO0 | GPIO17 | SIG |
3.3V | 3V3 | VCC |
GND | GND | GND |
![](https://learn.sunfounder.com/wp-content/uploads/2020/10/image-1709.png)
For C Users:
Step 2: Change directory.
cd /home/pi/SunFounder_SensorKit_for_RPi2/C/10_passive_buzzer/
Step 3: Compile.
gcc passive_buzzer.c -lwiringPi
Step 4: Run.
sudo ./a.out
For Python Users:
Step 2: Change directory.
cd /home/pi/SunFounder_SensorKit_for_RPi2/Python/
Step 3: Run.
sudo python3 10_passive_buzzer.py
Now you can hear the passive buzzer playing music..
![](https://learn.sunfounder.com/wp-content/uploads/2020/10/image-1711.png)