title: Variables and pattern reading
body: <p>Just started coding a few weeks ago, and a project I'm working on is a somewhat replica of the 'Simon' game (in which leds would light up in a certain pattern and the pattern would have to be inputted back into the game via push buttons)</p>
  <p>I've added variables for each button in order to get the pattern part of the code right, but it doesn't seem to be working. Is it something to do with that, or another problem entirely?</p>
  <pre><code>int ledPins[] = {10,11,12,13,6,7};
  const int buttonPin1 = 2;
  const int buttonPin2 = 3;
  const int buttonPin3 = 4;
  const int buttonPin4 = 5;
  int digitalVal1 = digitalRead(buttonPin1);
  int digitalVal2 = digitalRead(buttonPin2);
  int digitalVal3 = digitalRead(buttonPin3);
  int digitalVal4 = digitalRead(buttonPin4);
  int b1on = false;
  int b2on = false;
  int b3on = false;
  int b4on = false;
  int bcount = 0;
  int delayTime = 200;
  void firstpattern() {
    int delayTime = 200;
  
    digitalWrite(ledPins[1], HIGH);
    delay(delayTime);
  
    digitalWrite(ledPins[1], LOW);
    delay(delayTime);
  
    digitalWrite(ledPins[3], HIGH);
    delay(delayTime);
  
    digitalWrite(ledPins[3], LOW);
    delay(delayTime);
  
    digitalWrite(ledPins[2], HIGH);
    delay(delayTime);
  
    digitalWrite(ledPins[2], LOW);
    delay(delayTime);
  
    digitalWrite(ledPins[0], HIGH);
    delay(delayTime);
  
    digitalWrite(ledPins[0], LOW);
    delay(delayTime);
  
  
    delay(300);
  }
  
  void setup() {
  
    int index;
  
    for(index = 0; index &lt;= 4; index ++);
  
    {
      pinMode(ledPins[index], OUTPUT);
    }
  
    pinMode(buttonPin1,INPUT_PULLUP);
    pinMode(buttonPin2,INPUT_PULLUP);
    pinMode(buttonPin3,INPUT_PULLUP);
    pinMode(buttonPin4,INPUT_PULLUP);
  
    firstpattern();
  
  
  
  }
  
  void loop() {
  
  
    if(HIGH == digitalVal2) {
        if (b2on == false &amp;&amp; bcount == 0){
          b4on = false;
          b3on = false;
          b2on = true;
          b1on = false;
          bcount = bcount + 1;
    
    
      }
      else{
    
        digitalWrite(ledPins[4], HIGH);
      }
    }
  
    if (HIGH == digitalVal4) {
      if (b4on == false &amp;&amp; b2on == true &amp;&amp; bcount == 1){
        b4on = true;
        b3on = false;
        b2on = false;
        b1on = false;
        bcount = bcount + 1;
      }
  
      else{
    
        digitalWrite(ledPins[4], HIGH);
      }
    }
  
  
  
  
  
    if (HIGH == digitalVal3) {
      if (b3on == false &amp;&amp; b4on == true &amp;&amp; bcount == 2){
        b3on = true;
        b3on = false;
        b4on = false;
        b1on = false;
        bcount = bcount + 1;
      }
       else{
        
        digitalWrite(ledPins[4], HIGH);
      }
    }
    if (HIGH == digitalVal1) {
      if (b1on == false &amp;&amp; b3on == true &amp;&amp; bcount == 3){
        b1on = true;
        b3on = false;
        b2on = false;
        b4on = false;
        bcount = bcount + 1;
      }
    
      }
     if (bcount == 4){
      digitalWrite(ledPins[5], HIGH);
     }
      else{
       
        digitalWrite(ledPins[4], HIGH);
      }
  
  
  
  }
  </code></pre>