#define buzzerPin 27
#define buttonPin 15
int buttonState = 0;
void setup() {
Serial.begin(115200);
// Initialize the buzzer pin as an output
pinMode(buzzerPin, OUTPUT);
// Initialize the push button pin as an input
pinMode(buttonPin, INPUT);
}
void loop() {
// Read the state of the push button
buttonState = digitalRead(buttonPin);
// Check if the push button is pressed
if (buttonState == HIGH) {
// If the push button is pressed, turn on the buzzer
digitalWrite(buzzerPin, HIGH);
} else {
// If the push button is released, turn off the buzzer
digitalWrite(buzzerPin, LOW);
}
// Small delay for debouncing
delay(50);
}