title: Pushbutton variable change not working
body: <p>I am a few days into programming with Arduino and I've run into an annoying problem. My circuit contains three LEDs connected to pins 2,3,4 and a push button connected to pin 8. What I want to do is alternate the lit LED by pressing the button. I'm using a variable to count which LED is lit at a certain point and resets when it reaches the value 4. The hardware part works fine, because I've tested it separately (automated alternation of the LEDs and the button example program in the Arduino IDE), so there has to be something with my code. What is it exactly?</p>
  
  <pre><code>void setup(){
    pinMode(2, OUTPUT);
    pinMode(3, OUTPUT);
    pinMode(4, OUTPUT);
    pinMode(8, INPUT);
  
  }
  
  void loop(){
    int buton= digitalRead(8);
    int led = 1;
  
    if(led == 1){
      digitalWrite(2, HIGH);
      digitalWrite(3, LOW);
      digitalWrite(4, LOW);
    }
    if(led == 2){
      digitalWrite(2, LOW);
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
    }
    if(led == 3){
      digitalWrite(2, LOW);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
    }  
    if(buton == HIGH){
      led++;
      if(led == 4) led = 1;
    }
  
  }
  </code></pre>
  
  <p>I know for a fact that it doesn't enter the last if (the one for the button input value) because I've placed a Serial.println() to see both the value of variable led and a constant string and it didn't show.</p>
  
  <p>Thank you in advance!</p>