// Parameterizing pin numbers for better readability and maintainability
int buzzer = D0; // Assigning D0 to the variable 'buzzer'
int button = D1; // Assigning D1 to the variable 'button'
void setup() {
pinMode(buzzer, OUTPUT); // sets pin assigned to 'buzzer' as an output
pinMode(button, INPUT); // sets pin assigned to 'button' as an input
}
void loop() {
// Read the state of the button
if (digitalRead(button) == HIGH) {
// If the button is pressed, turn on the buzzer
digitalWrite(buzzer, HIGH); // sets pin assigned to 'buzzer' HIGH
} else {
// If the button is not pressed, turn off the buzzer
digitalWrite(buzzer, LOW); // sets pin assigned to 'buzzer' LOW
}
}