Changing from delay() to "without delay()"

Pady:
One question thou, can you explain what happens in

void myDelay(unsigned long t) {

for (unsigned long i = 0; i < t && !Next; i++) {
    delay(1);
    readButton();
  }
}

Well, like I said earlier, it breaks down long delays into a series of short delays. Between each short delay, your function gets called to check for button presses. So instead of only getting called once every 2 or 3 seconds, it gets called every 1 millisecond. If the switch is pressed and stays pressed longer than the debounce period, your global variable "Next" gets set to true. When that happens, the series of short delays gets aborted, and no other delays can be allowed until Next gets set to false again by the loop() function. So the remaining steps of animating the LEDs in whichever pattern is currently going on gets finished in a very short time (you can just see the LEDs flash briefly before the new pattern starts).

This technique is "quick and dirty", as we discussed earlier, and is OK in some situations but not all. If all that is being controlled is LEDs, it doesn't matter much if they flash briefly before the next sequence starts. But in other situations, where signals are being fed to other components for example, even brief unwanted signals will cause the circuit to not function as desired.

Paul