Editing existing LED flasher code

I’m still in the learning process and found a code that basically does what I want but with different patterns. I’m trying to make an LED flasher that changes pattern with a button push (which this code does, just not the patterns I’m trying to run). I would also like to make the last pattern loop through the other patterns and reset to the first pattern after the last button press. Can anyone tell me how to integrate my patterns into this existing code?

EXISTING CODE:

char mode = 0;
boolean pressed = false;

void clearLEDs();
boolean checkButton();

void setup() 
{
 pinMode(2, INPUT);
 for(int i = 6; i < 14; i++)
 {
   pinMode(i, OUTPUT);
   digitalWrite(i, LOW);
 }
}

void loop()
{  
 if(mode == 0 || mode == 2)
 {
   for(int i = 13; i >= 6; i--)
   {
     if(checkButton() == true)
       break;
     digitalWrite(i, HIGH);
     delay(100);
     digitalWrite(i, LOW);
   }
 }
 if(mode == 1 || mode == 2)
 {
   for(int i = 6; i <= 13; i++)
   {
     if(checkButton() == true)
       break;
     digitalWrite(i, HIGH);
     delay(100);
     digitalWrite(i, LOW);
   }
 }
}

void clearLEDs()
{
 for(int i = 6; i < 14; i++)
   digitalWrite(i, LOW);
}

boolean checkButton()
{
 char state = digitalRead(2);
 if(state == HIGH && pressed == false)
 {
   pressed = true;
   return false;
 }
 if(state == LOW && pressed == true)
 {
   mode++;
   if(mode > 2)
     mode = 0;
   clearLEDs();
   pressed = false;
   return true;
 }
 return false;
}

MY PATTERN 1

 digitalWrite(led, HIGH);             //Simultaneous Dual Flash
  digitalWrite(led2, HIGH);
  delay(100);
  digitalWrite(led, LOW);
  digitalWrite(led2, LOW);
  delay(60);

MY PATTERN 2

 digitalWrite(led, HIGH);               //Fast Wigwag
  delay(60);
  digitalWrite(led, LOW);
  delay(60);
  digitalWrite(led2, HIGH);
  delay(60);
  digitalWrite(led2, LOW);
  delay(60);

MY PATTERN 3

 digitalWrite(led, HIGH);         //Quint Flash Dual
  delay(40);
  digitalWrite(led, LOW);
  delay(40);
  digitalWrite(led, HIGH);
  delay(40);
  digitalWrite(led, LOW);
  delay(40);
  digitalWrite(led, HIGH);
  delay(40);
  digitalWrite(led, LOW);
  delay(40);
  digitalWrite(led, HIGH);
  delay(40);
  digitalWrite(led, LOW);
  delay(40);
  digitalWrite(led, HIGH);
  delay(40);
  digitalWrite(led, LOW);
  delay(40);
  digitalWrite(led, HIGH);
  delay(40);
  digitalWrite(led, LOW);
  delay(40);
  digitalWrite(led2, HIGH);
  delay(40);
  digitalWrite(led2, LOW);
  delay(40);
  digitalWrite(led2, HIGH);
  delay(40);
  digitalWrite(led2, LOW);
  delay(40);
  digitalWrite(led2, HIGH);
  delay(40);
  digitalWrite(led2, LOW);
  delay(40);
  digitalWrite(led2, HIGH);
  delay(40);
  digitalWrite(led2, LOW);
  delay(40);
  digitalWrite(led2, HIGH);
  delay(40);
  digitalWrite(led2, LOW);
  delay(40);
  digitalWrite(led2, HIGH);
  delay(40);
  digitalWrite(led2, LOW);
  delay(40);

Just to make things easier, you need to first tidy up your post.

Go and read the instructions, then go back and modify your post (use the "More --> Modify" option to the bottom right of the post) to mark up the code as such so we can examine it conveniently and accurately.

If you do not do this, the code you post could well be garbled and is certainly anything but easy to read.

Note: Also mark up any data in the same way. This includes error output that you get from the IDE.

And - before you post code, use "Auto Format" in the Tools menu to properly present the code.

Thank you Paul__B. I've reformatted the post now.

In both the example, and your code... there is a common newbie trait... Nothing wrong with it, but it makes the code far longer, more complex and harder to understand!

Look into arrays[], and combining your patterns into one function() Then simply running the loop will change which LEDs are flashing, based on the array members which are cinfigured/in use.

Once that's done and working, you can look into removing the delay() calls which in 'most' good code are never used... but that's for later.

Get to work on defining pin and LED arrays, then sequencing through them. There have been several posts within the last week that discuss this exact idea.