I was bored so I will give you a head start by removing all the delays in your code.
just redesign the loop code to read a button and advance rather than letting the state advance on its own (remove the timer in the loop also as it replacing large delays in your original code)
got bored naming things so im sure you can use edit-find word and replace with better names
// ALBERO DI NATALE
byte ledArray[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
byte leftArray[] = {12, 7, 5, 8, 3, 4};
byte rightArray[] = {11, 9, 2, 10, 6, 13};
byte oddArray[] = {2, 9, 11, 4, 7, 5, 12, 6, 8, 3, 10};
unsigned long previousMillis1 = 0;
unsigned long previousMillis2 = 0;
unsigned long previousMillis3 = 0;
unsigned long previousMillis4 = 0;
unsigned long previousMillis5 = 0;
unsigned long currentMillis;
byte state = 0;
unsigned long wait;
void setup() {
Serial.begin(9600);
for (byte x = 0; x < 12; x = x + 1) {
//do this 12 times
pinMode (ledArray[x], OUTPUT);
}
}
void loop() {
currentMillis = millis();
if (currentMillis - previousMillis4 >= wait) {
switch (state) {
case 0:
previousMillis5 = currentMillis;
state = 1;
break;
case 1:
pattern1();
break;
case 2:
pattern2();
break;
case 3:
pattern3();
break;
case 4:
pattern4();
break;
}
}
}
void pattern1() {
static byte ledOn;
if (currentMillis - previousMillis5 >= 1000) {
ledOn=1;
}
if (ledOn==0){
for (byte x = 0; x < 12; x = x + 1) {
digitalWrite (ledArray[x], HIGH);
}
}else{
for (byte x = 0; x < 12; x = x + 1) {
digitalWrite (ledArray[x], LOW);
}
previousMillis4 = currentMillis;
wait = 1000;
state = 2;
ledOn=0;
}
}
void pattern2() {
static byte ledDir;
static byte ledPosition;
if (currentMillis - previousMillis1 >= 500) {
if (ledDir == 0) {
digitalWrite (ledArray[ledPosition], HIGH);
ledPosition++;//add to counter called ledPosition
} else {
digitalWrite (ledArray[ledPosition], LOW);
ledPosition--;
}
previousMillis1 = currentMillis;//take a new time stamp
}
if (ledPosition >= 12) {
ledDir = 1;
}
if (ledPosition <= 0) {
ledDir=0;
ledPosition = 0;
previousMillis4 = currentMillis;
wait = 1500;
state = 3;
}
}
void pattern3() {
static byte cycle;
if (currentMillis - previousMillis2 >= 1000) {
cycle++;
previousMillis2 = currentMillis;
}
switch (cycle) {
case 1:
for (byte x = 0; x < 6; x = x + 1) {
digitalWrite (leftArray[x], HIGH);
}
break;
case 2:
for (byte x = 0; x < 6; x = x + 1) {
digitalWrite (rightArray[x], HIGH);
}
break;
case 3:
break;
case 4:
for (byte x = 0; x < 6; x = x + 1) {
digitalWrite (leftArray[x], LOW);
}
break;
case 5:
for (byte x = 0; x < 6; x = x + 1) {
digitalWrite (rightArray[x], LOW);
}
previousMillis4 = currentMillis;
wait = 1500;
cycle = 0;
state = 4;
break;
}
}
void pattern4() {
static byte ledthing;
static byte even;
static byte ledspot;
byte oddArray[] = {2, 9, 11, 4, 7, 5, 12, 6, 8, 3, 10};
if (currentMillis - previousMillis3 >= 500) {
ledthing++;
if (even == 1) {
digitalWrite (oddArray[ledspot], HIGH);
} else {
digitalWrite (oddArray[ledspot], LOW);
ledspot++;
}
previousMillis3 = currentMillis;
}
if (ledthing >= 24) {
digitalWrite(13, LOW);
ledthing = 0;
ledspot = 0;
previousMillis4 = currentMillis;
wait = 1500;
state = 0;
} else {
digitalWrite(13, HIGH);
}
even = ledthing % 2;
}