setup:When the Arduino is powered up, this section operates once. It instructs the Arduino on which pins to utilize for the push button (an input) and the LEDs (an output). With the INPUT_PULLUP setting, the button will be "HIGH" (on) by default and "LOW" (off) when pressed, simplifying the wiring by utilizing an internal resistor. loop This code segment executes continually. It continuously verifies whether the button has been pushed. press button. The code detects a "LOW" signal when you press the button. To ensure that it's a genuine press and not just a brief flicker, it then waits a very short time (delay(50)) a process known as debouncing. It increments the currentPattern variable to the next pattern if the button is still pressed. When the number reaches the final pattern, the % numPatterns section ensures that it loops back to 0. pattern; to execute the LED pattern, the switch statement in the loop() function verifies the value of currentPattern and invokes the relevant function. The precise instructions for turning the LEDs on and off with delays to produce the appropriate blinking effect are contained in each pattern function (pattern1(), pattern2()
https://wokwi.com/projects/442627870219631617
Add a video of the output (know more)