Sequence LEDS

I want to make my LED do this
Sequence 1 – Red on for 3 sec followed by Green on for 3 sec followed by Yellow on for 2 sec. Repeat.
Pressing the button will switch to sequence 2.
Sequence 2 – Red and green flashed alternately for 0.5 sec each for 5 sec followed by Yellow on for 5 sec. Stop.
This is my code but it is not working

//code
int button = 12;
int red = 10;
int yellow = 9;
int green = 8;
int val;
int val2;
int State;
int Mode = 0;
void setup() {
Serial.begin(9600);
pinMode(button, INPUT);
pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);
State = digitalRead(button);
}
void loop() {
{
int State = digitalRead(button);
Serial.println(State);
}
val = digitalRead(button);

val2 = digitalRead(button);
if (val == val2) {
if (val != State) {
if (val == LOW) {
if (Mode == 0) {
Mode = 1;
} else {
if (Mode == 1) {
Mode = 2;
} else {
if (Mode == 2) {
Mode = 3;
} else {
if (Mode == 3) {
Mode = 0;
}
}
}
}
}
}
State = val;
}
if (Mode == 0) { // all-off
digitalWrite(red, LOW);
digitalWrite(yellow, LOW);
digitalWrite(green, LOW);
}
if (Mode == 1) { //Red is blinks at SOS

digitalWrite(red, HIGH);
delay(3000);
digitalWrite(red, LOW);

digitalWrite(green, HIGH);
delay(3000);
digitalWrite(green, LOW);

digitalWrite(yellow, HIGH);
delay(2000);
digitalWrite(yellow, LOW);
}
if (Mode == 2) { ////Yellow is on but you need to hold for 800ms to switch to the next.

digitalWrite(green,LOW);
digitalWrite(red,HIGH);
delay(500);

digitalWrite(red,LOW);
digitalWrite(green,HIGH);
delay(500);

digitalWrite(yellow, HIGH);
delay(5000);
digitalWrite(yellow, LOW);

}
if (Mode == 3) { //green is on
digitalWrite(red, LOW);
digitalWrite(yellow, LOW);
digitalWrite(green, LOW);
}
}

Not only does it not work, your words, it's not posted in code tags nor is it properly formatted. If you could put the code in code tags, after formatting it, that would be a great start.

Another thing. your code sleeps for about 14 seconds. If, during the 14 seconds you, me, the guy next to you presses a button, the code will not respond to that button push.

You can do the tutorial about using millis() and then do the other one about multiple things at the same time, using millis(). If you are using a ESP32 you can really do multiple things at the same time and multi-threading by using the built in freeRTOS operating system.

OK, first things first.

You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the "More -> Modify" option below the right hand corner of your post - to mark up your code as such using the "</>" icon in the posting window. Just highlight each section of code (or output if you need to post that) from the IDE and click the icon.

In fact, the IDE itself has a "copy for forum" link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don't forget to use the "Auto-Format" (Ctrl-T) option first to make it easy to read. If you do not post it as "code" it can easily be quite garbled and is always more difficult to read due to the font.

Just to mention, it is inappropriate to attach it as a ".ino" file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And even that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only single blanks between complete functional blocks.

How about this:
5 LEDs on pins 2, 3, 11, 12, 13
they flash randomly and go out randomly
it is possible to switch differently in the code and thus sort when each LED goes out or lights up ...

/*
* Blink_Randomly edit 5 leds
*
* Modified from the basic Arduino example.  Turns an LED on for a random time,
* then off for a (most likely) different random time.  We use pin 13 because,
* depending on your Arduino board, it has either a built-in LED
* or a built-in resistor so that you need only an LED.
*
* Original at - http://www.arduino.cc/en/Tutorial/Blink
* 
* 
*/


// edit JM Zvukservis.cz 
// randomly Bilnk 5 colors

// lcd display 16-2 ( lcd KeyPad ) 
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int ledPinR = 2;  // red color
int ledPinG = 3;  // Green color
int ledPinB = 11; // Blue Color 
int ledPinY = 12; // Yellow Color
int ledPinW = 13; // White Color

 
long randOn = 0;                  
long randOff = 0;                 

void setup()                      // run once, when the sketch starts
{
   lcd.begin(16, 2);
   lcd.setCursor(0, 0); 
   lcd.print("Semafor Blikatko");  // name ... 
 randomSeed (analogRead (0));    // randomize
 pinMode(ledPinR, OUTPUT);  
 pinMode(ledPinG, OUTPUT);
 pinMode(ledPinB, OUTPUT);
 pinMode(ledPinY, OUTPUT);
 pinMode(ledPinW, OUTPUT);      
}

void loop()      
                 
{

  
 randOn = random (100, 1600);    // generate ON time between 0.1 and 1.2 seconds
 randOff = random (700, 1300);   // generate OFF time between 0.2 and 0.9 seconds
 
   digitalWrite(ledPinR, HIGH); // On red color
   lcd.setCursor(2, 1); 
   lcd.print("R");               // sets the LED on
   delay(randOn);                // waits for a random time while ON

   digitalWrite(ledPinB, LOW);   // sets the LED off // off Blue Color
   lcd.setCursor(6, 1);
   lcd.print(" ");   
   delay(randOff);            // waits for a random time while OFF


   digitalWrite(ledPinG, HIGH);  // sets the LED on // on greeen Color
   lcd.setCursor(4, 1); 
   lcd.print("G");  
   delay(randOn);  
   
   digitalWrite(ledPinR, LOW);    // sets the LED off// Off Red Color
   lcd.setCursor(2, 1); 
   lcd.print(" ");                
   delay(randOff);               // waits for a random time while OFF

   digitalWrite(ledPinY, HIGH); // ON Yellow color
   lcd.setCursor(8, 1); 
   lcd.print("Y");   // sets the LED on
   delay(randOn); 
      
   digitalWrite(ledPinG, LOW);  // Off Green Color
   lcd.setCursor(4, 1); 
   lcd.print(" ");   
   delay(randOff);  
                   
   digitalWrite(ledPinB, HIGH);  //on Blue Color
   lcd.setCursor(6, 1); 
   lcd.print("B");  // sets the LED on
   delay(randOn);                

   digitalWrite(ledPinW, LOW);  // Off White Color
   lcd.setCursor(10, 1);
   lcd.print(" ");   
   delay(randOff); 
                               
   digitalWrite(ledPinY, LOW);  // off Yellow color
   lcd.setCursor(8, 1); 
   lcd.print(" ");   
   delay(randOff);               
    
   digitalWrite(ledPinW, HIGH); // On White color
   lcd.setCursor(10, 1);
   lcd.print("W");   
   delay(randOn); 

                     // end 
}

Is this a reply to a dead thread or what?