title: I am using a button as a switch, it turns on but doesn't turn off (Arduino)
body: <p>I am trying to make a button work as a switch. The code works to turn the lights "on" but the code doesn't want to turn them off.</p>
  
  <p>My code works like so:</p>
  
  <ol>
  <li>If button is pressed and the lights are off, turn on the lights.</li>
  <li>If button is pressed and the lights are on, turn off the lights.</li>
  </ol>
  
  <p>But number 2 doesn't work.</p>
  
  <pre><code>int buttonStatus = 0;
  int check = 1;
  int Status = 0;
  
  void setup() {
    pinMode(5,OUTPUT);
    pinMode(7,OUTPUT);
    pinMode(9,OUTPUT);
    pinMode(11,OUTPUT);
    pinMode(13,OUTPUT);
    pinMode(2,INPUT);
  }
  
  void loop() {
    if (check = 1) {
      buttonStatus = digitalRead(2);
      if (buttonStatus == HIGH &amp;&amp; Status == 0) {
        Status = 1;
        buttonStatus = 0;
      } else if (buttonStatus == HIGH &amp;&amp; Status == 1) {
        Status = 0;
        buttonStatus = 0;
      }
    }
  
    if (Status == 1) {
      digitalWrite(5,HIGH);
      delay(50);
      digitalWrite(5,LOW);
      digitalWrite(7,HIGH);
      delay(50);
      digitalWrite(7,LOW);
      digitalWrite(9,HIGH);
      delay(50);
      digitalWrite(9,LOW);
      digitalWrite(11,HIGH);
      delay(100);
      digitalWrite(11,LOW);
      digitalWrite(13,HIGH);
      delay(100);
      digitalWrite(13,LOW);
    } else {
      digitalWrite(5,LOW);
      digitalWrite(7,LOW);
      digitalWrite(9,LOW);
      digitalWrite(11,LOW);
      digitalWrite(13,LOW);
    }
  }
  </code></pre>