#define relay 11
#define switch_1 37

int state = 0;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(switch_1, INPUT_PULLUP);
  pinMode(relay, OUTPUT);
}

void loop() {
  digitalWrite(relay, state);
  if (digitalRead(switch_1) == LOW){
    delay(50);
    while (true) {
      delay(50);
      if (digitalRead(switch_1) == HIGH) {
        break;
      }
    }
    if (state == 1) {
      state = 0;
    } else {
      state = 1;
    }
  }
  delay(10); // this speeds up the simulation
}