Here is my idea
int[] array = new int[5];
int actionCounter = 0;
int timer;
void setup() {
size(600, 600);
background(128);
for (int i = 0; i < array.length; i++) {
array[i] = int(random(4));
}
println(array);
timer = millis();
}
void draw() {
background(128);
showAction() ;
if (millis()-timer >= 1100) {
actionCounter++;
timer = millis();
}
}
void showAction() {
if (actionCounter == 0) {
fill(0);
rect(200, 200, 100, 100);
} else if (actionCounter == 1) {
// delay(300);
fill(255, 0, 0);
rect(200, 200, 100, 100);
} else if (actionCounter == 2) {
fill(0, 255, 0);
rect(200, 200, 100, 100);
} else if (actionCounter == 3) {
fill(0, 0, 255);
rect(200, 200, 100, 100);
} else if (actionCounter == 4) {
fill(255);
rect(270, 200, 100, 100);
}//if
}