const int buttonPin = 3; // Pin connected to the button
const int buzzerPin = 15; // Pin connected to the buzzer
void setup() {
pinMode(buttonPin, INPUT_PULLUP); // Initialize the buttonPin as an input
pinMode(buzzerPin, OUTPUT); // Initialize the buzzerPin as an output
}
void loop() {
int buttonState = digitalRead(buttonPin); // Read the state of the button
if (buttonState == LOW) { // Button is pressed
digitalWrite(buzzerPin, HIGH); // Turn on the buzzer
delay(1000); // Buzzer on for 1 second
} else {
digitalWrite(buzzerPin, LOW); // Turn off the buzzeer
}
}