LED sequence control by button
My original answer was probably over-kill....Just keep track of how many leds are lit:

int ledPins[] = {3, 4, 5,};
const int num_leds = sizeof(ledPins) / sizeof(ledPins[0]);  // 3 in this example
byte num_leds_lit = 0

void set_leds() {
    for (int i = 0; i &lt; num_leds; i++) {
        digitalWrite(ledPins[i], i &lt; num_leds_lit ? HIGH : LOW);
    }
}


Then, on button press, increase the count:

if (num_leds_lit &lt; num_leds) {
    num_leds_lit += 1;
    set_leds();
}


Then to turn the leds off with the other button press:

if (num_leds_lit &gt; 0) {
    num_leds_lit -= 1;
    set_leds();
}


------------------------- Original answer

There are a few ways to do it. One way would be to use a bitmask. I would write a function to turn the leds on/off

// Each bit represents the state of one LED (0 == off, 1 == on)
byte led_bits = 0;
int ledPins[] = {3, 4, 5,};
const int num_leds = sizeof(ledPins) / sizeof(ledPins[0]);  // 3 in this example
// Need a mask to make sure we don't set too many bits
const byte led_mask = 0xFF &gt;&gt; 8 - num_leds;   // 00000111B in this case

void set_leds() {
    for (int i = 0; i &lt; num_leds; i++) {
        // Turn on/off based on state of bit
        digitalWrite(ledPins[i], (1 &lt;&lt; i) &amp; led_bits ? HIGH : LOW);
    }
}


Then, on button press, set the mask:

led_bits &lt;&lt; = 1;          // Shift left (001 -&gt; 010)
led_bits |= 1;            // Set lsb    (010 -&gt; 011)
led_bits &amp;= led_mask;     // Ensure max bits: (1111 -&gt; 0111)
set_leds();


Then to turn the leds off with the other button press:

led_bits &gt;&gt;= 1;          // Shift right (011 -&gt; 001)
set_leds();