Arduino Projects

How to Use Passive and Active Buzzer with Arduino

Passive and Active Buzzer Introduction:

In the previous article, we let Arduino control the DC motor. let’s play with sound! The easiest way to make Arduino make sounds is to use a passive and active buzzer.

Buzzers are basically divided into two categories: active buzzers and passive buzzers. The active buzzer has a built-in set of fixed frequencies and will emit a fixed tone as long as it is powered on. Passive buzzer is different. We have to tell it the frequency through the program so that we can get the required tone, but we can use it to play simple melody!

The appearance of active buzzers and passive buzzers are very similar. Generally, active buzzers will have a white sticker on them. In addition, there will also be a glue seal on the bottom of active buzzers. Passive buzzers will have a similar appearance. The circuit board can be seen directly from the bottom.

Passive and Active Buzzer




Amazon links:

Arduino Nano USB-C Type (Recommended)

Active Buzzer

Passive Buzzer

Wires

10KΩ resistor

Breadboard

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!



Passive buzzer Arduino circuit connection

Passive and Active Buzzer

as you can see the circuit diagram is simple, i connected passive buzzer directly to pin 9 of the Arduino with using a current-limiting resistor regardless of the positive and negative poles.The other pin is connected to GND, as shown in the picture above.

Passive buzzer program:




Active Buzzer Driver Circuit Connection

Active buzzers differ from passive buzzers as they typically require a driver circuit for proper operation. A typical driver circuit is as follows:

Passive and Active Buzzer

In the circuit above, an NPN-type transistor serves as the control switch. In LS1, the collector of the buzzer transistor is connected to GND, the emitter is linked to the negative terminal of the buzzer, and a 10K resistor connects the base of the transistor to the GPIO pin of the microcontroller. The positive terminal of the buzzer connects to VCC.

The transistor in this configuration acts as a switch, operating as follows:

When the GPIO outputs a high level, there’s no voltage difference between the base and the emitter of the transistor, thus no current flows between the emitter and the collector. Consequently, no current passes through the buzzer (LS1), and it remains silent.

Conversely, when the GPIO outputs a low level, a voltage difference arises between the base and the emitter, causing the transistor to conduct. This allows current to flow through the buzzer (LS1). If it’s an active buzzer, it emits an immediate beep.

The transistor model used in this circuit is 2N2222, with pin configuration as follows:

Passive and Active Buzzer

Pin 1 = E (emitter, the pin on the left side of the triode in the circuit diagram)

Pin 2 = B (base, the pin in the middle of the triode in the circuit diagram)

Pin 3 = C (collector, the pin on the right side in the circuit diagram)



Active Buzzer with Arduino circuit connection:

Passive and Active Buzzer

The positive pin of the active buzzer connects to 5V, while the negative terminal connected to the emitter (E) of the transistor. The base (B) of the transistor connects to a 10K ohm resistor, which then connects to Arduino pin D5. Finally, the collector (C) of the transistor connects to the ground.



Active buzzer program:

Code explanation:

This code is a simple Arduino sketch designed to control a buzzer component connected to pin D5 (digital pin 5) of the Arduino board. Let’s break it down step by step:

This line declares an integer variable named pinBuzzer and initializes it with the value 5. This variable is used to specify which pin of the Arduino board is connected to the buzzer.

The setup() function is a standard Arduino function that runs once when the Arduino board is powered on or reset. In this function, pinMode(pinBuzzer, OUTPUT); sets the pin specified by pinBuzzer (which is pin D5) to be an output pin. This means that the Arduino will use this pin to send voltage signals out to control external components.

The loop() function is another standard Arduino function that runs repeatedly after the setup() function completes. In this function, the Arduino turns the buzzer on for 3 seconds digitalWrite(pinBuzzer, HIGH); by setting the pin specified by pinBuzzer to a high voltage level. Then it waits for 3 seconds delay(3000);. After that, it turns the buzzer off digitalWrite(pinBuzzer, LOW); by setting the pin to a low voltage level and waits for 1 second delay(1000);. This pattern repeats indefinitely, creating a simple on-off sound pattern with the buzzer.

 

 

 

 

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button