// practice how to add buzzer and use it
int speakerPin = 8;
int switchPin = 11;
void setup() {
pinMode(speakerPin, OUTPUT);
pinMode(switchPin, INPUT);
}
void loop() {
if (digitalRead(switchPin) == HIGH) {
tone(speakerPin, 4000);
}
else {
noTone(speakerPin);
}
}