What delays? There are no delays in the BlinkWithoutDelay example. So if there are any delays in your code, then you introduce them. It's relatively simple if you can wrap your mind around the loop. It runs constantly, every millisecond. If you need something to be running constantly, great, you're done. If you have other things that don't need to be running constantly, then set a delay based on millis() in them. Consider this code:
int pause = 250;
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, (digitalRead(13) == HIGH ? LOW : HIGH));
delay(pause);
}
Now, compare it to this:
int tickMillis = 0;
int pause = 250;
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
// I only want this LED to turn on or off every 250 ms (the length of pause)
if (millis() - tickMillis > pause) {
digitalWrite(13, (digitalRead(13) == HIGH ? LOW : HIGH));
tickMillis = millis();
}
}
They do exactly the same thing, except the first one uses the delay() function whereas the second one doesn't. But that LED is still only blinking every 250 ms. Using the first code, you are always waiting for that delay() call to finish before anything else can happen. With the second one you don't need to because the loop will just continue to run regardless of whether the time has passed or not - it only affects the LED IF that "pause" has been reached. So anything outside of that if statement will keep running each time the loop cycles.
You can create another if statement that will only run every 5 seconds. Your LED will still continue to blink every 250ms, regardless. Put a button check outside of the if statement and you can continuously check its state and react to it, rather than waiting for a cycle (which has a delay() in it) to finish before it doing something.
So you have to rethink your code and remove all your delays() and instead think in millis() and how to use it to simulate a delay(). I just wrote a long post myself the other night of how I created a light display for my daughter that reacts to a button, and has an indicator LED. You can read the post
here. The button falls outside of anything, so it's always sampled. The indicator LED has it's own timing, regardless of the delays within each light pattern (which change each time, so even that isn't fixed.)