Active Buzzer

In this lesson, you will learn how to generate a sound with an active buzzer.

Component Required:

  • 1 x Uno R3

  • 1 x Active buzzer

  • 1x 830 Tie Points Breadboard

  • 2x M-M wires (Male to Male jumper wires)

BUZZER:

Electronic buzzers are DC-powered and equipped with an integrated circuit. They are widely used in computers, printers, photocopiers, alarms, electronic toys, automotive electronic devices, telephones, timers and other electronic products for voice devices. Buzzers can be categorized as active and passive ones. Turn the pins of two buzzers face up. The one with a green circuit board is a passive buzzer, while the other enclosed with a black tape is an active one.

Connection Diagram:

Wiring schematic:

Physical wiring diagram:

Code:

After wiring add the "pitches.h" library. Download this file below.

You can click here to see how to add a library.

#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 < 12; thisNote++) {
    // pin12 output the voice, every scale is 0.5 sencond
    tone(12, melody[thisNote], duration);
    delay(100);
    // Output the voice after several minutes
    delay(100);
  } // restart after two seconds
  delay(200);
}

You can also download the code below

Last updated