The easiest way to do what you want is to use bit-fields that represents each state of the LED's and an array definig the corresponding pins:
#define NUM_LEDS 4
#define PATTERN_SIZE 5
//The pins used for LED's
const byte LEDS[NUM_LEDS] = { 13, 12, 11, 10 };
//A binary representation of the first pattern
const byte PATTERN_1[PATTERN_SIZE] = {
0b00000000,
0b00000001,
0b00000010,
0b00000100,
0b00001000,
0b00010000,
};
//A binary representation of the second pattern
const byte PATTERN_2[PATTERN_SIZE] = {
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
};
void show_pattern(const byte* pattern)
{
for (byte i = 0; i < PATTERN_SIZE; i++)
{
for (byte p = 0; p < NUM_LEDS; p++)
{
digitalWrite(LEDS[p], (pattern[i] & (1 << p)) != 0 ? HIGH : LOW);
}
delay(400);
}
}
void setup()
{
//Your setup code here..
}
void loop()
{
byte switch1 = digitalRead(4);
byte switch2 = digitalRead(5);
if ((switch1 == LOW) && (switch2 == LOW)) show_pattern(PATTERN_1);
else if ((switch1 == LOW) && (switch2 == HIGH)) show_pattern(PATTERN_2);
else
{
for (byte p = 0; p < NUM_LEDS; p++) digitalWrite(LEDS[p], LOW);
}
}
The code is untested and deliberate bugs are included. Now you can figure out how to fix it!