I’m with @Moors7 here, I would use a variable to hold the delays - encode them as a comma separated list, e.g.
`0,1000,200,250,0,800,500,1000’
You can then send this variable to the spark using the cloud api. This makes it easy to hook up the behaviour to a front end running the UI and a bit of javascript. On the spark, you’d split the received string at commas using strtok, and convert the individual values from strings to integers using atoi(), which you store in an array.
To start the display, again, using the cloud, I’d expose a playback
function, which you can call using the cloud function api.. On the spark, this function could work like this:
void playback(String args) { // the function called, with the list of delays
int delays[8]; // 8 delays, parsed from the string passed to the function
parseDelays(delayVariable, delays); // split the string and store values in an array
uint32_t start = millis(); // time corresponding to offset 0
for (;;) {
uint32_t now = millis()-start; // find the current time after the start
for (int i=0; i<8; i++) {
digitalWrite(i, delay[i]<=now); // if the delay is less or equal than now, turn the output on
}
if (now>=1000) // are we done?
break;
}
}
void setup() {
Spark.function("playback", playback);
}
This isn’t complete code, just a sketch to show you a simple way to tackle the problem. There are certainly plenty of ways to improve this code, but I wanted to keep it simple at the start!
Regarding timing, the total delay is a second, so your code wont be interrupted by the cloud once playback starts. The code above should run with accuracy down to the millisecond.
When extending to using the 8 analog pins, I believe you can use digitalWrite() on these also.
Hope this helps!