#Project objective: To test a passive buzzer to play an alarm sound at one second interval
#Hardware and connections used:
#Passive buzzer GND to Raspberry Pi Pico GND
#Passive buzzer + Pin to GPIO Pin 15
#If passive buzzer is used, import the Speakerclass
from picozero
from picozero import Speaker
from time import sleep
#creating a speaker object
speaker = Speaker (15)
#Continuously beep at 1 sec interval while the board has power
#Note: a passive buzzer can also be used to play different tones
while True:
speaker. On ()
sleep (1)
speaker. Off ()
sleep (1)