delay makes hardware button unresponsive

Hi. I set up my radiant heating system with an Arduino and rigged a normal, household thermostat to work with it. Everything works fine except that I want the water pump relay to stay on for 5 minutes after the heat relay turned off (cooling). No problem I thought. I just put a delay function. Problem is that the thermostat has a hardwired button and during the delay the program freezes and won’t respond to button input. Is there a way for the loop to keep going but still have a 5 minute pump ON function kick in every time the heating relay is switched to off, no matter what?

By the same token, I am using several if statements so the heater will only heat if particular conditions are met. But I do want and LED to blink a certain number of times depending on which part of the function it is in. But I do NOT want the loop to stop for let's say 7 seconds when I have an LED blink with 1 second intervals. I need: blink 7 times slowly but let loop continue while blinking.

Thank you kindly

delay() does freeze program execution for that amount of time.

If you want some code to proceed while other parts of code is being delayed, use milis() as in the 'Blink Without Delay' example that is in examples in the IDE.

Robin2 has an example of how to do several things at one time.
https://forum.arduino.cc/index.php?topic=223286.0

And
https://forum.arduino.cc/index.php?topic=503368.0

.