int swtch = 2;
int relay = 3;

void setup() {
  // put your setup code here, to run once:
  pinMode(swtch, INPUT_PULLUP); //set saklar menjadi aktif low seolah-olah ada rangkaian resistor pullup
  pinMode(relay, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
 int statusSW = digitalRead(swtch);
 if(statusSW==LOW){
   digitalWrite(relay, HIGH);
 }
 else{
   digitalWrite(relay, LOW);
 }
}