int buzzer = 4;
int sw1 = 11;
int sw2 = 10;
int sw3 = 9;
int sw4 = 8;
void setup()
{
pinMode(buzzer, OUTPUT);
pinMode(sw1, INPUT_PULLUP);
pinMode(sw2, INPUT_PULLUP);
pinMode(sw3, INPUT_PULLUP);
pinMode(sw4, INPUT_PULLUP);
}
void beep(int times) {
for (int i = 0; i < times; i++){
tone(buzzer,1500);
delay(200);
noTone(buzzer);
delay(200);
}
}
void loop(){
if (digitalRead(sw1) == LOW) {
beep(1);
}else if (digitalRead(sw2) == LOW) {
beep(2);
}else if (digitalRead(sw3) == LOW) {
beep(3);
}else if (digitalRead(sw4) == LOW) {
beep(4);
}
}