A buzzer is an electromechanical or piezoelectric component that produces a characteristic sound—a beep—when voltage is applied to it. It consists of a diaphragm that reacts to the piezoelectric effect.
It can be controlled by the Raspberry Pi board using a square wave signal that represents the frequency of the note.
Here is the electronic schematic to connect the buzzer to the Raspberry Pi board:
Programming
For programming the buzzer, we offer you two programs: one to produce a beep, and the other to play a melody from the buzzer.
Here is the program to produce multiple beeps from the buzzer:
Here is the program to play a melody using the buzzer: