#define pinSwitch 13
#define pinRelay 15
#define buzzer 12

void setup() {
  pinMode(pinSwitch, INPUT_PULLUP);
  pinMode(pinRelay, OUTPUT);
  pinMode(buzzer, OUTPUT);
}

void loop() {
  int nilaiSwitch = digitalRead((pinSwitch));
  if(nilaiSwitch == 0){
    digitalWrite(pinRelay, HIGH);
    tone(buzzer, 200);
    delay(100);
  }
  else{
    digitalWrite(pinRelay, LOW);
    noTone(buzzer);
  }
}