In this example we take a look at the KY-006 Passive Buzzer Module and connect this to a Raspberry Pi.
The KY-006 Buzzer Module can generate tones between 1.5 to 2.5 kHz by switching on and off at different frequencies either using delays or PWM.
Lets talk about the piezo buzzer – this is from wikipedia
A piezoelectric speaker (also known as a piezo bender due to its mode of operation, and sometimes colloquially called a “piezo”, buzzer, crystal loudspeaker or beep speaker) is a loudspeaker that uses the piezoelectric effect for generating sound. The initial mechanical motion is created by applying a voltage to a piezoelectric material, and this motion is typically converted into audible sound using diaphragms and resonators.
Compared to other speaker designs piezoelectric speakers are relatively easy to drive; for example they can be connected directly to TTL outputs, although more complex drivers can give greater sound intensity. Typically they operate well in the range of 1-5kHz and up to 100kHz in ultrasound applications.
Piezoelectric speakers are frequently used to generate sound in digital quartz watches and other electronic devices, and are sometimes used as tweeters in less-expensive speaker systems, such as computer speakers and portable radios. They are also used for producing ultrasound in sonar systems. Piezoelectric speakers have several advantages over conventional loudspeakers: they are resistant to overloads that would normally destroy most high frequency drivers, and they can be used without a crossover due to their electrical properties.
There are also disadvantages: some amplifiers can oscillate when driving capacitive loads like most piezoelectrics, which results in distortion or damage to the amplifier.
Additionally, their frequency response, in most cases, is inferior to that of other technologies, especially with regards to bass and midrange. This is why they are generally used in applications where volume and high pitch are more important than sound quality.
Piezoelectric speakers can have extended high frequency output, and this is useful in some specialized circumstances; for instance, sonar applications in which piezoelectric variants are used as both output devices (generating underwater sound) and as input devices (acting as the sensing components of underwater microphones).
They have advantages in these applications, not the least of which is simple and solid state construction that resists seawater better than a ribbon or cone based device would.
|Raspberry Pi 4
|Aliexpress product link
|37 sensor kit
|AliExpress Product link
|Aliexpress product link
We use pin 40 (GPIO 21) in this example, you can use another GPIO pin.