from machine import Pin
import time
# Initialize the button and buzzer
button = Pin(3, Pin.IN, Pin.PULL_UP)
buzzer = Pin(15, Pin.OUT)
while True:
if button.value() == 0: # Button is pressed
print("Button pressed")
buzzer.value(1) # Turn on the buzzer
time.sleep(1) # Buzzer on for 1 second
else:
buzzer.value(0) # Turn off the buzzer