🐷 Tutorial 17 - Passive Buzzer
🐷 Tutorial 17 - Passive Buzzer
A passive buzzer is an electronic component that produces an audible sound when a voltage is applied to it. It consists of a piezoelectric buzzer element without supporting circuitry, and it requires an external signal to produce a tone.
When a voltage is applied to a passive buzzer, it causes the piezoelectric element to vibrate at a specific frequency, producing an audible tone. The frequency of the tone depends on the design of the buzzer element and the voltage and frequency of the signal applied to it.
Passive buzzers are commonly used in a variety of electronic devices and circuits, such as musical instruments, toys, and other applications where a simple audible tone is required. They are often used in conjunction with microcontrollers, switches, or sensors to produce an audible alert or notification.
One advantage of passive buzzers is that they are relatively simple to use and require only a simple connection to a voltage source to operate. They also provide a consistent and reliable output, making them ideal for use in a wide range of applications.
Overall, passive buzzers are an important component in electronic circuits and devices, providing a simple and effective way to produce an audible sound for various types of alerts and notifications.
Components Needed
Component | Quantity |
---|---|
Raspberry Pi Pico W | 1 |
Micro USB Cable | 1 |
Breadboard | 1 |
Wires | Several |
S8550 | 1 |
S8050 | 1 |
Fritzing Diagram
Code
import machine
import utime
buzzer = machine.PWM(machine.Pin(15))
def tone(pin,frequency,duration):
pin.freq(frequency)
pin.duty_u16(30000)
utime.sleep_ms(duration)
pin.duty_u16(0)
tone(buzzer,440,250)
utime.sleep_ms(500)
tone(buzzer,494,250)
utime.sleep_ms(500)
tone(buzzer,523,250)