#define BUZZER_PIN 7 // Buzzer connected to pin 7
#define BUTTON_PIN 4 // Push button connected to pin 4
void setup() {
pinMode(BUZZER_PIN, OUTPUT); // Set Buzzer pin as output
pinMode(BUTTON_PIN, INPUT_PULLUP); // Set button pin as input with internal pull-up resistor
}
void loop() {
if (digitalRead(BUTTON_PIN) == LOW) { // Check if button is pressed
digitalWrite(BUZZER_PIN, HIGH); // Turn Buzzer on
} else {
digitalWrite(BUZZER_PIN, LOW); // Turn Buzzer off
}
}